0

我在 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 中试过这个但没有用..

4

2 回答 2

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

在 xml 文件中设置它以调用块

于 2012-08-20T10:03:10.747 回答
0

只需在您的主 phtml 文件中回显以下代码:

$this->getLayout() ->getBlockSingleton('aitshopassist/assistant')->setTemplate('aitshopassist/assistant.phtml')->toHtml();
于 2013-10-23T08:51:51.450 回答