0

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

2

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 behavior – snh_nl Feb 1 '17 at 19:12
  • See my updated answer. – Adarsh Khatri Feb 2 '17 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.