【问题标题】:Magento: how to add a static block AFTER product listMagento:如何在产品列表之后添加静态块
【发布时间】:2015-09-08 01:16:19
【问题描述】:

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

【问题讨论】:

    标签: magento static-block


    【解决方案1】:

    在您的 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 块,请在 catalog/product/list.phtml..

    底部附近添加以下内容
     <?php
         $catcode = Mage::registry('current_category')->getId();
         echo $this->getLayout()->createBlock('cms/block')->setBlockId('category_block_' . $catcode .'')->toHtml(); 
     ?>
    

    创建每个类别的 CMS 块,标识符为 category_block_categoryid

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 1970-01-01
    相关资源
    最近更新 更多