【问题标题】:Set Default template for category page in Magento在 Magento 中为类别页面设置默认模板
【发布时间】:2014-06-02 12:28:35
【问题描述】:

Magento 新手。

谁能指导我如何定义类别页面的默认布局。

在我的主题文件夹中尝试了 local.xml 但不起作用。

这是我的 xml 文件:-

<!-- Default handle, loaded on most pages -->
<default>

    <reference name="head">

        <!-- Remove Magento's default assets -->
        <action method="removeItem">
            <type>skin_css</type>
            <name>css/print.css</name>
        </action>
        <action method="removeItem">
            <type>skin_css</type>
            <name>css/styles-ie.css</name>
        </action>
        <action method="removeItem">
            <type>skin_css</type>
            <name>css/styles.css</name>
        </action>
        <action method="removeItem">
            <type>skin_css</type>
            <name>css/widgets.css</name>
        </action>
        <action method="removeItem">
            <type>skin_js</type>
            <name>js/ie6.js</name>
        </action>
        <action method="removeItem">
            <type>js</type>
            <name>lib/ds-sleight.js</name>
        </action>
        <action method="removeItem">
            <type>js</type>
            <name>varien/menu.js</name>
        </action>

        <!-- Add our assets -->
        <action method="addCss">
            <stylesheet>css/font-awesome.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/jquery-ui.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>dist/css/style.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/ddSlick.css</stylesheet>
        </action>
        <action method="addCss">
            <stylesheet>css/parsjewellers.css</stylesheet>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>js/jquery-1.11.1.min.js</name>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>js/jquery-ui.js</name>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>js/ddSlick_jquery.dropdown.js</name>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>dist/js/script.js</name>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>js/my_site.js</name>
        </action>

        <!-- Add additioanl child blocks -->
        <block type="core/template" name="boilerplate.head.meta" template="boilerplate/page/html/head/meta.phtml"/>
        <block type="core/template" name="boilerplate.head.ie8" template="boilerplate/page/html/head/ie8.phtml"/>

    </reference>

    <reference name="header">
        <block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
    </reference>

    <reference name="right">
        <remove name="paypal.partner.right.logo" />
        <remove name="right.permanent.callout" />
        <remove name="right.poll" />
        <remove name="cart_sidebar" />
        <remove name="catalog.compare.sidebar" />
    </reference>

    <reference name="left">
        <remove name="currency" />
        <remove name="left.permanent.callout" />
        <remove name="tags_popular" />
        <remove name="left.newsletter" />
    </reference>

</default>

<catalog_category_default>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    </reference>
</catalog_category_default>


<print>

    <reference name="head">

        <!-- Add our assets -->
        <action method="addCss">
            <stylesheet>css/style.css</stylesheet>
        </action>
        <action method="addItem">
            <type>skin_js</type>
            <name>js/script-ck.js</name>
        </action>

    </reference>

</print>

任何帮助将不胜感激。

谢谢

【问题讨论】:

    标签: magento


    【解决方案1】:

    我使用分层导航,我的 xml 更新被覆盖 catalog_category_layered 句柄

    <?xml version="1.0" encoding="UTF-8"?>
    <layout>
        <catalog_category_default>
            <reference name="root">
                <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
            </reference>
        </catalog_category_default>
        <catalog_category_layered>
            <reference name="root">
                <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
            </reference>
        </catalog_category_layered>
    </layout>
    

    【讨论】:

      【解决方案2】:

      更改个别类别页面布局

      您可以通过以下步骤修改每个单独类别的页面布局:

       1. Go to Catalog -> Manage Categories
       2. Select any category
       3. Click the 'Custom Design' tab
       4. Select your desired page layout from 'Page Layout' selectbox
       5. Save Category and you are done!
      

      从您的 local.xml 文件中更改类别页面:

       1. Open layout/local.xml file
       2. Find the node 'catalog_category_default' and add
      
      <catalog_category_default>
      
              <reference name="root">
                  <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
              </reference>
      </catalog_category_default>
      

      另一种方法:

       1. Open layout/page.xml file
       2. Under the ‘default’ node, you will find the following code
      
      <block type="page/html" name="root" output="toHtml" template="page/2columns-left.phtml">
      

      上面一行设置了2columns-left布局。您可以将其更改为您想要的选择,例如 2columns-right3columns 等。

      P.S:如果使用分层导航,需要使用&lt;catalog_category_layered&gt;节点来改变布局。

      【讨论】:

      • 感谢您的回复。第一种方法不适合我这就是为什么我已经尝试过第二种方法 正如你在我的问题中看到的那样。但不知道为什么那不起作用。
      • 在您的类别页面上启用模板路径提示并查看正在调用的布局
      • 解决了这个问题。我的 xml 更新被分层导航中的 catalog_category_layered 覆盖。
      猜你喜欢
      • 1970-01-01
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-04
      • 2016-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多