I'm using yii2 and pagination I want to change page number to post id because I want to use pagination for images so instead of page=2 or page=3 it will be image=88 or image=909 ...
Related
I am using Drupal with the Commerce Module to build a webshop. I am using the Commerce Cart Block to display a cart icon with the amount of items in the cart, in the navigation bar.
Now I would also like to display the Cart Block on the Cart page, but with a different template than being used in the navigation bar.
I am using the debug mode, which let me see what I could call the file names to use them like I would like to. But above both Cart Blocks it says the same file name, so I can't output two different templates. I tried putting primary_menu-- before the navigation cart block and content-- (the region the cart block is going to be in), but they don't work.
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'commerce_cart_block' -->
<!-- BEGIN OUTPUT from 'themes/custom/verdamigo/templates/commerce-cart-block.html.twig' -->
This is shown above both cart blocks (which are on the same page). So how can I use two different templates for both blocks.
primary_menu--commerce-cart-block.html.twig
is not working.
I would like to be able to edit both the block in the primary_menu and the block in the content-region. But both carts get output with the same template.
In an effort to decouple Blocks from Displays, Drupal 8 renders a block independently of which display it's in and what region/weight it has in that display (see Twig Template naming conventions) :
Region-specific block templates are not available in Drupal 8.
This removes the ability to override block.tpl.php by region, and for hook_preprocess_block() to adjust variables based on it. Instead, core developers recommend to manage block template overrides with CSS or using additional blocks.
But you can still work around this by implementing hook_theme_suggestions_HOOK_alter() :
function SOME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
if (!empty($variables['elements']['#id'])) {
$block_id = $variables['elements']['#id'];
$block = Drupal\block\Entity\Block::load(block_id);
$region = $block->getRegion();
// Allow per-region block templating.
$suggestions[] = 'block__' . $region . '__' . $block_id;
}
return $suggestions;
}
Note : the template name should begin with "block" since you override a block template, so in your case the override file should be named block--primary_menu--commerce-cart-block.html.twig.
Hi I have a database which I can access in a view using
html and express layout I think #each and {{}} is a js syntax
{{posts[0].detail}} <----------------This works
But I want to display all the contents of the post using
#each(post in posts)
{{post[don't know what to put here].detail}}
#end
What about {{post.detail}} from #Cristy
So this answered my question.
I thought #each(post in posts) <----- you had to use posts.detail
Now I know post takes the attribute of posts.
Ex:
#each(post in cars) <------ would still be post.detail as well.
I want to add a custom search on frontend(magento). So i want to add 2 or 3 attributes on frontend to make a custom/advanced search. I have tried to add catalosearch/advanced to frontend but the attributes are not showing as dropdown menu like product page.
Thanks :)
First make the attribute to be searcheable from admin. Catalog->attribute->manage attributes. Enable used in quick search and used in advanced search.
Then get all the searcheable attribute by this
$attributes = array();
foreach ($this->getSearchableAttributes() as $_attribute):
$attributes[$_attribute->getAttributeCode()] = $_attribute;
endforeach;
Show the attribute by this $attributes['attribute_code'];
You simply need to click on manage properties and check the frontend properties of that particular attribute. You just need to change the following :
Visible on Product View Page on Front-end - Yes
Makes the attribute searchable
I want to display two listboxes like in C# to add or remove items.
Is there a option in twitter bootstrap?
I tried out the
<div class="list-group"></div>
But there is no option to post this data to the next page without a js function.
Maybe bootstrap duallistbox plugin -> http://www.virtuosoft.eu/code/bootstrap-duallistbox/ will suit your needs?
In the file main.php at views/layouts/main.php, I want to add few classes to the body tag and add css class 'active' to the navigation bar items according to the view being displayed. Is there any way I can get action id in main.php?
I hope that html is not req
Or you can use:
Yii::$app->controller->id // get controller name
to access the controller, and:
Yii::$app->controller->action->id // get action name
for getting the current action id. But put this directive at the top of file:
use Yii;
In a layout you can access the current controller via $this->context, and so the current action id by $this->context->action->id