如何使用local.xml在Magento 1.5中设置默认布局? [英] How to set a default layout in Magento 1.5 using local.xml?

查看:79
本文介绍了如何使用local.xml在Magento 1.5中设置默认布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经完成了一些我想使用的布局,并且我认为在local.xml文件中进行设置可以解决每个页面的问题.像这样

So I've done some layouts that I want to use and I was thinking that setting this in your local.xml file would fix this for every page. Like this

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

但是这什么也没做.相反,如果我去

This however doesn't do anything. Instead if I go

...<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>...

,依此类推,在每个特定的页面上都会对其进行更改.我是在想错还是这是唯一的方法?

and so on for every specific place it gets changed on those specific pages. Am I thinking wrong or this the only way to do it?

推荐答案

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

The problem you're (probably) running into is that something comes along later and sets the template for the root block again, overriding your change.

Magento的最新版本(1.4somethingish)引入了一种防止这种情况发生的方法.如果您查看page.xml,将会看到类似这样的句柄

More recent versions of Magento (1.4somethingish) introduced a way to prevent this from happening. If you look in page.xml, you'll see a handle like this

<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句柄已应用于您的请求,或者您使用手动将其应用

If the page_one_column handle gets applied to your request, or you manually apply it with

<update handle="page_one_column" />

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

Magento will change the template and call the setIsHandle method on the block.

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

Magento中的代码将查找IsHandle属性,如果为true,则将忽略对setTemplate的进一步调用. (这有点过分简化,但或多或​​少是正确的)

There's code in Magento that will look for the IsHandle property, and if it's true, further calls to setTemplate will be ignored. (that's over-simplifying things a bit, but is more or less true)

尝试类似

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

看看是否有帮助.

请记住,这是目前尚不清楚第三方开发商是否应该涉足的那些灰色地带之一.而且,更改所有页面的模板 可能会对期望位于某个模板中的网站部分产生不良影响.

Keep in mind this is one of those grey areas where it's not clear if third party developers are supposed to tread. Also, changing the template for all pages may have un-desirable effect on parts of the site that expect to be in a certain template.

这篇关于如何使用local.xml在Magento 1.5中设置默认布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆