Add CSS class to {{block type="cms/block" block_id="my_block1"}}
This now outputs as html here, but I see widget block add a DIV tag around it with a CSS ID.
Question: How can we add a tag around block type="cms/block" and echo some css class like the BlockId()
<div class="cms-block my_block1">html here</div> where my_block1 is the block id
1 Answer 1
You cannot do that unless you want to overwrite template for it. Widget block and a DIV tag you are seeing are coming from default widget handler.
If all you want to add css class then how about this way? Wrapping with div?
<div class="cms-block my_block1">{{block type="cms/block" block_id="my_block1"}}</div>
Hope this helps.
UPDATE
Check template file called template/cms/widget/static_block/default.phtml. This file is responsible for that DIV.
-
Yes this would work. Just find it strange that widget adds the div and block does not. Wondering where to override cms block to show same behaviorsnh_nl– snh_nl2017年02月01日 19:12:17 +00:00Commented Feb 1, 2017 at 19:12
-
See my updated answer.Adarsh Khatri– Adarsh Khatri2017年02月02日 06:09:09 +00:00Commented Feb 2, 2017 at 6:09