Rav*_*thi 10 php block magento content-management-system
我需要在页脚中显示更多链接.我在magento admin中创建了这些链接作为静态块(id = sample_links).
然后我添加了以下代码page.xml文件
<reference name="foot_lnk">
<block type="cms/block" name="sample_block" before="-">
<action method="setBlockId"><block_id>sample_links</block_id></action>
</block>
</reference>
Run Code Online (Sandbox Code Playgroud)
我在footer.phtml中称这个为,
<?php echo $this->getChildHtml('foot_lnk') ?>
Run Code Online (Sandbox Code Playgroud)
但它不显示CMS静态块内容.问题是什么?
swa*_*esh 20
$this->getLayout()->createBlock('cms/block')->setBlockId('my_static_block_name')->toHtml()
Run Code Online (Sandbox Code Playgroud)
Ale*_*ley 14
引用是先前定义的块,您希望块在内部,例如:
<reference name="footer">
<block type="cms/block" name="sample_links">
<action method="setBlockId"><block_id>sample_links</block_id></action>
</block>
</reference>
Run Code Online (Sandbox Code Playgroud)
然后
<?php echo $this->getChildHtml('sample_links') ?>
Run Code Online (Sandbox Code Playgroud)
你可以调用一个statick块,如:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_identifier')->toHtml() ?>
Run Code Online (Sandbox Code Playgroud)
并调用一个块,如:
<?php echo $this->getLayout()->createBlock('sidebar/left')->setTemplate('bannerslider/left.phtml')->tohtml(); ?>
Run Code Online (Sandbox Code Playgroud)
访问magevn.com查看更多用例在magento中使用块.