加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何使用local.xml在Magento 1.5中设置默认布局?

发布时间:2020-12-15 23:58:21 所属栏目:百科 来源:网络整理
导读:所以我已经完成了一些我想要使用的布局,并且我认为在local.xml文件中设置它会为每个页面修复此问题.像这样 defaultreference name="root" action method="setTemplate" templatepage/mytheme.phtml/template /action/reference/default 然而,这没有做任何事
所以我已经完成了一些我想要使用的布局,并且我认为在local.xml文件中设置它会为每个页面修复此问题.像这样
<default>
<reference name="root">
    <action method="setTemplate">
      <template>page/mytheme.phtml</template>
    </action>
</reference>
</default>

然而,这没有做任何事情.相反,如果我去

...<customer_account_forgotpassword>
  <reference name="root">
    <action method="setTemplate"><template>page/mytheme.phtml</template></action>
  </reference>
</customer_account_forgotpassword>  

<customer_account_confirmation>
  <reference name="root">
    <action method="setTemplate"><template>page/mytheme.phtml</template></action>
  </reference>
</customer_account_confirmation>...

对于每个特定的地方,它都会在这些特定的页面上被更改.我在想错还是这是唯一的方法呢?

您(可能)遇到的问题是稍后会出现问题并再次为根块设置模板,从而覆盖您的更改.

更新版本的Magento(1.4somethingish)介绍了一种防止这种情况发生的方法.如果你查看page.xml,你会看到这样的句柄

<page_one_column translate="label">
    <label>All One-Column Layout Pages</label>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
        <!-- Mark root page block that template is applied -->
        <action method="setIsHandle"><applied>1</applied></action>
    </reference>
</page_one_column>

如果page_one_column句柄应用于您的请求,或者您手动应用它

<update handle="page_one_column" />

Magento将更改模板并在块上调用setIsHandle方法.

<action method="setIsHandle"><applied>1</applied></action>

Magento中的代码将查找IsHandle属性,如果是真的,将忽略对setTemplate的进一步调用. (这有点过分简化了事情,但或多或??少都是真的)

尝试类似的东西

<default>
    <reference name="root">
        <action method="setTemplate">
          <template>page/mytheme.phtml</template>
        </action>
        <action method="setIsHandle">
            <applied>1</applied>
        </action>       
    </reference>
</default>

看看是否有帮助.

请记住,这是一个灰色地带,不清楚第三方开发商是否应该采取行动.此外,更改所有页面的模板可能会对期望位于特定模板中的部分网站产生不希望的影响.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读