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

asked Jan 31, 2017 at 22:11

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.

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.