现在的位置: 首页 > 综合 > 正文

How to call a static block from template files

2018年02月07日 ⁄ 综合 ⁄ 共 1262字 ⁄ 字号 评论关闭

to add a static block into footer.phtml:
1) add a new static block (in this example Identifier is my_footer_block)
2) layout/page.xml in:
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
add a:
<block type="cms/block" name="my_footer_block"><action method="setBlockId"><block_id>my_footer_block</block_id></action></block>
so in this example it will looks like:
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
                <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
                <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
                <block type="cms/block" name="my_footer_block"><action method="setBlockId"><block_id>my_footer_block</block_id></action></block>
</block>
3) in footer.phtml - comment default links and add your block call:
<div class="informational">
    <?php //echo $this->getChildHtml() ?>
    <?php echo $this->getChildHtml('my_footer_block') ?>
</div>

PS. but to add a link to your footer links you can always use this construction:
<reference name="footer_links">
          <action method="addLink" translate="label title"><label>Your Path</label><url>your/path/</url><title>Your Path</title></action>
</reference>

hope its help

抱歉!评论已关闭.