2

I am creating category page and i want to add two static blocks to it. While I was going through CMS/Static Blocks, I realized I can Only add One Static Block to any page. I couldn't find anything where i can add 2 or more static blocks. Is there a way i can add two or more such static blocks in a single category page.

  • Amit, are you want to manage from admin??? – Amit Bera Mar 12 '14 at 4:56
4

You can add any number of static blocks in any page in anywhere as you desire.

Since you need to add two static blocks.. create two static blocks through admin.(CMS -> Static Blocks). Let the identifiers used for two static blocks be mystaticblock_1 and mystaticblock_2. Then you can use following code directly in your page (phtml file) in order to display your static block

  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('mystaticblock_1')->toHtml() ?> 
  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('mystaticblock_2')->toHtml() ?> 

You can also add static blocks through your layout file. An example is shown below

<handler_correspond_to_desired_page>
<reference name="content">
    <block type="cms/block" name="my_staticblock_1">
        <action method="setBlockId"><block_id>mystaticblock_1</block_id></action>
    </block> 
    <block type="cms/block" name="my_staticblock_2">
        <action method="setBlockId"><block_id>mystaticblock_2</block_id></action>
    </block> 
</reference>
</handler_correspond_to_desired_page>

Then go to the template file where you need to display the static block and add the following code in the appropriate location

<?php echo $this->getChildHtml('my_staticblock_1') ?>
<?php echo $this->getChildHtml('my_staticblock_2') ?>

There is lot of tutorials regarding this topic. Please make a ruff idea about static blocks and their usages. Good luck

| improve this answer | |
  • where is template file in which I need to add {{block type="cms/block" block_id="IDENTIFIER"}} – Sudhir Belagali Oct 13 '15 at 7:49
  • @SudhirBelagali sorry I didnt get your question – Rajeev K Tomy Oct 13 '15 at 7:54
  • Oh sorry sir my question is wrong ,,can u please tell me the location of template file in magento – Sudhir Belagali Oct 13 '15 at 9:10
2

In Category page you can technically call any number of static blocks within a static block via

{{block type="cms/block" block_id="IDENTIFIER"}}

But all static blocks will be displayed in only one location which is described in your category's template .phtml file (usually above products listings)

If you want to display static block in other location you can go with xml Custom Layout Updates or even edit your .phtml files.

Regards

| improve this answer | |

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.