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

1 Answer 1

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.

2
  • 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
    Commented Feb 1, 2017 at 19:12
  • See my updated answer. Commented Feb 2, 2017 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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