在Magento PHTML文件中显示静态块

时间:2014-06-28 18:16:21

标签: php xml magento

我在2columns-right.phtml文件中使用以下代码将Mangento管理面板中的堆栈块调用到产品页面上:

<?php echo $this->getChildHtml('right') ?> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('recipes')->toHTML(); ?>

我的catalog.xml中也有这个代码:

<reference name="right">
<block type="cms/block" name="recipes">
<action method="setBlockId"><block_id>recipes</block_id></action>
</block>
</reference>

没有任何内容呈现在页面上。我已经回复了一些虚拟文本并在正确的位置呈现,所以我知道有正确的.phtml文件,但我没有得到阻止的迹象。

1 个答案:

答案 0 :(得分:0)

local.xml

下创建app/design/frontend/your package/your template/layout/

并输出以下代码

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="right">
            <block type="cms/block" name="recipes" before="cart_sidebar"  output="toHtml">
                <!--
                    The content of this block is taken from the database by its block_id.
                    You can manage it in admin CMS -> Static Blocks
                -->
                <action method="setBlockId"><block_id>recipes</block_id></action>
            </block>
        </reference>
    </default>

同时检查cms块是exiting or not in admin and also check store select or not。如果是多店退出

相关问题