3

在一个网站中,我的老板希望我在该类别的产品列表之后插入一个静态块。到目前为止,使用 Magento 前端应用程序,你可以在这里看到,我已经看到我只能在产品列表之前添加一个静态块。如何将块放在每个类别的产品列表之后?例如这个是我正在处理的网站的一个页面,我想在页面底部显示该块,在产品列表之后但在页脚链接之前。我想我应该更改一些文件(例如 page.xml 或 local.xml),因为我不知道怎么做,而且我还没有在网上找到任何有用的东西。你能帮我吗?

4

1 回答 1

6

在您的local.xml添加以下内容,将 cms_extra 替换为您的 CMS 块的标识符。

 <!-- Catalog Category (Anchor) -->
 <catalog_category_layered>
     <reference name="content">
         <block type="cms/block" name="cms_extra" after="category.products">
             <action method="setBlockId"><block_id>cms_extra</block_id></action>
         </block>       
     </reference>
 </catalog_category_layered>

 <!-- Catalog Category (Non-Anchor) -->
 <catalog_category_default>
     <reference name="content">
         <block type="cms/block" name="cms_extra" after="category.products">
             <action method="setBlockId"><block_id>cms_extra</block_id></action>
         </block>
     </reference>
 </catalog_category_default>

或者,如果需要在每个类别上使用不同的 CMS 块,请在目录/产品/list.phtml底部附近添加以下内容。

 <?php
     $catcode = Mage::registry('current_category')->getId();
     echo $this->getLayout()->createBlock('cms/block')->setBlockId('category_block_' . $catcode .'')->toHtml(); 
 ?>

使用category_block_ categoryid标识符创建每个类别的 CMS 块

于 2015-06-22T14:33:50.373 回答