简体   繁体   中英

How can I add a unique second static block to every category page at the bottom? with magento

I want to add a second static block to the bottom of every category page in my magento 1.9 store.

Like this site

I want a description on top of the products but also a larger description at the bottom.

I am very familiar with magento and hard coding but it seems I get stuck here. I search the web for ours but no solution.

I could manage it to get a static block at the footer but then on every page it is the same text and I want different text at each category.

You can do this through layout.xml. To add a static block simply add:

<block type="cms/block" name="block_key">
    <action method="setBlockId">
        <block_id>block_key</block_id>
    </action>
</block>

to the content node on the category section. Then you can call it via:

    <?php echo $this->getChildHtml('block_key'); ?>

where ever you would like in your template.

To add custom text you can use the magic set method which you will add to the custom design section on the category page.

<reference name="block_key">
    <action method="setCustomText">
         <text>This is my custom text</text>
    </action>
</reference>

Then within your template/block you can get this from using the following :

<?php echo $this->getCustomText(); ?>

Let me know if this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM