如何在Magento的所有页面中添加cms静态块?

时间:2011-11-04 10:03:07

标签: magento-1.4 magento-1.5 magento

我是magento的新手,我正在尝试为我的家,类别和其他页面创建一个静态块。我希望静态块显示在页脚链接的正上方。是否有任何良好的在线教程可以提供静态块的良好视图。如何在CMS中使用它们以及如何使用PHP代码生成它们。

3 个答案:

答案 0 :(得分:12)

直接向模板添加静态和非静态块:

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

另一个块或cms页面内的短代码:

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

For Reference Visit Here

答案 1 :(得分:0)

<?php 
    echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')->toHtml(); 
    // toy can use this code in your template file.    
?>

在您的cms页面中使用,如短代码

{{block type="cms/block" block_id="your_block_id"}} 
// used in your cms pages like a short code

答案 2 :(得分:0)

在.phtml文件中显示静态块:

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

在CMS页面中显示静态块:

{{block type="cms/block" block_id="my_block" template="cms/content.phtml"}}