在Magento主页上显示自定义块

时间:2012-08-06 20:57:06

标签: php magento

我看到了这个答案Static block on home page in Magento,但无法使其发挥作用。

我只是想在我的主页中添加自定义块。这些是我做过的事情:

1-将此添加到我的布局文件中。

<cms_index_index>
    <reference name="content">
       <block type="aitshopassist/assistant" name="aitshopassist_assistant" template="aitshopassist/assistant.phtml">
           <action method="setBlockId"><block_id>shop_assistant_block</block_id>
           </action>
       </block>
     </reference>
</cms_index_index>

2-将此添加到2columns-right.phtml文件中:

<?php echo $this->getChildHtml('shop_assistant_block') ?>

此外,该块在catalog_category_view中正确显示。

我错过了什么?

<catalog_category_view>
    <reference name="content">
        <block type="aitshopassist/assistant" name="aitshopassist_assistant" template="aitshopassist/assistant.phtml" before="category.products" />
    </reference>
</catalog_category_view>

我在cms_index_index中尝试了这个但是没有用..

2 个答案:

答案 0 :(得分:2)

 <block type="cms/block" name="aitshopassist_assistant" before="-">
        <action method="setBlockId"><block_id>shop_assistant_block</block_id></action>
  </block>

将其设置在xml文件中以调用块

答案 1 :(得分:0)

只需回复主页phtml文件中的以下代码:

$this->getLayout() ->getBlockSingleton('aitshopassist/assistant')->setTemplate('aitshopassist/assistant.phtml')->toHtml();
相关问题