简体   繁体   English

在Magento PHTML文件中显示静态块

[英]Display Static Block in Magento PHTML File

I'm using the following code in my 2columns-right.phtml file to call a stack block made in the Mangento admin panel onto a product page: 我在2columns-right.phtml文件中使用以下代码,将在Mangento管理面板中创建的堆栈块调用到产品页面上:

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

I also have this code in my catalog.xml: 我的catalog.xml中也有以下代码:

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

Nothing is rendering on to the page. 页面上没有任何内容。 I've echoed some dummy text and that's rendered in the right spot so I know have the right .phtml file, but I am getting no sign of the block. 我已经回显了一些伪文本,这些文本在正确的位置呈现,因此我知道具有正确的.phtml文件,但是我没有看到该块的迹象。

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

and out the below code 和下面的代码

<?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>

also check cms block is exiting or not in admin and also check store select or not .If multi store exit 还要检查cms块是否exiting or not in admin and also check store select or not存储。如果多商店退出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM