【问题标题】:Weird Layout Behaviour in Magento Layout local.xmlMagento 布局 local.xml 中的奇怪布局行为
【发布时间】:2014-02-25 06:20:01
【问题描述】:

有一个奇怪的,我有点困惑,因为我很确定我在这里做的一切都是正确的。

我正在使用 Magento CE 1.8.1.0,这是我目前的 local.xml:

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <!-- Blocks to Remove from Layout -->
        <remove name="paypal.partner.right.logo" />
        <remove name="right.permanent.callout" />
        <reference name="right">
            <remove name="right.poll" />
        </reference>
        <reference name="head">
            <action method="addItem"><type>skin_css</type><name>css/combined.css</name></action>
            <action method="addJs"><script>modernizr/modernizr-2.6.2-respond-1.1.0.min.js</script></action>
        </reference>
        <reference name="before_body_end">
            <block type="page/html_head" name="footer_scripts" as="footerScripts" after="-" template="page/html/footer/footer-scripts.phtml">
                <action method="addJs"><script>jquery/jquery-1.11.0.min.js</script></action>
                <action method="addItem"><type>skin_js</type><name>js/combined.js</name></action>
            </block>
        </reference>
    </default>
</layout>

我遇到的问题是根模板设置不正确。它使用基本的 2columns-right.phtml 文件。我在这里错过了什么?

【问题讨论】:

  • 你想在哪个页面上设置2columns-left.phtml?所以你必须在适当的句柄上设置模板
  • 我想把它设置为默认的根模板。这已经排序,因为我忘记进入 CMS 页面部分并设置模板。

标签: xml magento templates layout php


【解决方案1】:

目前无法深入代码,但我猜是因为您使用默认句柄,它会被其他布局句柄覆盖

【讨论】:

    【解决方案2】:

    对于那些在检查完其他所有内容后还在为这个问题摸不着头脑的人。

    由于主页本质上是一个 CMS 页面,它在“CMS > 页面 > 主页 > 设计 > 布局”下分配了一个默认模板,因此无论您如何在布局 XML 文件(本地. xml) 它将始终使用在 CMS 中配置的那个。只需将其更改为您想要的,它将使用您的自定义 .phtml 文件,如您的 local.xml 中指定的那样。

    【讨论】:

      猜你喜欢
      • 2018-04-19
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多