[英]Display Static Block in Magento PHTML File
我在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文件,但是我沒有看到該塊的跡象。
在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
存儲。如果多商店退出
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.