【问题标题】:Display Static Block in Magento PHTML File在 Magento PHTML 文件中显示静态块
【发布时间】:2014-08-19 14:48:19
【问题描述】:

我在我的 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 文件,但我没有得到块的迹象。

【问题讨论】:

  • 检查你的静态块状态是否启用

标签: php xml magento


【解决方案1】:

app/design/frontend/your package/your template/layout/下创建local.xml

下面的代码

<?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 。如果多商店退出

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多