【问题标题】:Magento: Display block after category descriptionMagento:类别描述后显示块
【发布时间】:2012-09-18 22:48:47
【问题描述】:

我无法在类别页面上的类别描述之后放置一个块。

我有一个单独的布局 xml 文件,用于新的过滤导航。 xml是:

 <catalog_category_layered> 
    <remove name="catalog.leftnav" />
    <remove name="enterprisecatalog.leftnav"/> 
    <reference name="left">
       <block type="amshopby/catalog_layer_view" name="amshopby.navleft" after="currency" template="catalog/layer/view.phtml"/>
    </reference>
    <reference name="content">
            <block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="-" template="amshopby/view_top.phtml"/>
            <block type="amshopby/top" name="amshopby.top" before="category.products" template="amshopby/top.phtml"/>
    </reference>
</catalog_category_layered> 

所以正是这一行将这个块放置在我的类别页面内容区域的开头:

<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="-" template="amshopby/view_top.phtml"/>

所以现在我的分类页面是这样的:

过滤导航 -> 分类标题 -> 分类描述 -> 产品概览

但我想重新排列它,使其看起来像

分类标题 -> 分类描述 -> 过滤导航 -> 产品概览

但是我怎样才能把这个块放在描述之后呢?这是一个包含标题、描述、产品等的新块:

(标准目录.xml)

 <catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="left"></reference>
    <reference name="content">
        <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
            <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                <!-- <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/su.phtml</template></action> -->
                <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                    <block type="page/html_pager" name="product_list_toolbar_pager"/>
                    <!-- The following code shows how to set your own pager increments -->
                    <!--
                        <action method="setDefaultListPerPage"><limit>4</limit></action>
                        <action method="setDefaultGridPerPage"><limit>3</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>3</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>6</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>9</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
                    -->
                </block>
                <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
                <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
            </block>
        </block>
    </reference>
</catalog_category_layered> 

我真的不知道如何在类别描述之后添加这个块。我是 magento 的新手,块系统很混乱。我尝试过类似

<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="product_list_toolbar" template="amshopby/view_top.phtml"/>

但这不起作用。我也尝试在catalog.xml中添加这个块代码,但它没有显示出来。

有人知道我能做什么吗?感谢您的帮助!

【问题讨论】:

  • 我的建议是,过滤导航(又名分层导航)是左侧部分的一部分。您需要将其从左侧删除并添加到目录中的content 部分中。在magento/app/design/frontend/base/default/template/catalog/category/view.phtml 中找到行&lt;?php if($_description=$this-&gt;getCurrentCategory()-&gt;getDescription()): ?&gt;。在 if 条件调用 $this-&gt;getChildHtml('amshopby.navtop') 之后。这应该有效。但是有了经验,您将需要更多的调整

标签: magento


【解决方案1】:

amshopby.xml 中,剪切以下XML 行:

<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" before="-" template="amshopby/view_top.phtml"/>
<block type="amshopby/top" name="amshopby.top" before="category.products" template="amshopby/top.phtml"/>

然后在catalog.xml,将这两行粘贴到这里:

<catalog_category_layered translate="label">
<!-- ... -->
<reference name="content">
<!-- ... -->
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">

<!-- paste XML here -->

<!-- ... -->
</reference>
</catalog_category_layered>

然后在template/catalog/category/view.phtml这一行粘贴:

<?php echo $this->getChildHtml('amshopby.navtop'); ?>

在以下之后:

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
    <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
</div>
<?php endif; ?>

应该可以的。

【讨论】:

  • 感谢您的回答。但是当我尝试这个时,没有显示 amshopby 块中的任何内容。没有错误,只是空白。
  • 您是否在category.products 块之后粘贴了这两行XML?我已经为我正在使用改进导航模块的商店完成此操作,并且运行良好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多