Php 在magento布局中使用更新句柄设置根模板失败

Php 在magento布局中使用更新句柄设置根模板失败,php,magento,Php,Magento,我使用以下命令将新的布局句柄应用于联系人页面: <update handle="test_contacts_set_root" /> 我可以验证是否正在应用布局句柄 不幸的是,以下方法现在不起作用了: <test_contacts_set_root> <reference name="root"> <action method="setTemplate"><template>page/1column.pht

我使用以下命令将新的布局句柄应用于联系人页面:

<update handle="test_contacts_set_root" />

我可以验证是否正在应用布局句柄

不幸的是,以下方法现在不起作用了:

<test_contacts_set_root>
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
</test_contacts_set_root>

第/1页column.phtml
这是更改根模板的非常标准的布局代码。不幸的是,当应用自定义布局句柄时,它没有效果

我怀疑这与布局系统中的某种排序或其他有关

下面是my contacts.xml的完整内容

<layout version="0.1.0">
    <default>
        <reference name="footer_links">
            <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
        </reference>
    </default>

    <contacts_index_index translate="label">
        <label>Contact Us Form</label>
        <reference name="head">
            <action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
        </reference>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
        </reference>

        <update handle="test_contacts_set_root" />

        <reference name="content">
            <block type="core/template" name="contactForm" template="contacts/form.phtml"/>
        </reference>
    </contacts_index_index>

    <test_contacts_set_root>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
    </test_contacts_set_root>

</layout>

联系我们联系我们
联系我们表格
联系我们
第页/2列-right.phtml
联系我们
第/1页column.phtml

您为布局提供了两种不同的说明:首先,magento尝试使用handle test\u contacts\u set\u root并尝试设置1列模板,然后它遇到中的命令“嘿,将模板设置为2列right.phtml”


第页/2列-right.phtml
联系我们

Magento不考虑指令在xml节点中的放置顺序。因此,首先,它将查看块之后的句柄,并且仅在执行块渲染操作期间。您可以查看Mage\u Core\u Model\u Layout和Mage\u Core\u Model\u Layout\u Update以了解详细信息。

但Update handle标签显示在这两个标签中的最后一个。如何确保执行更新句柄last@MartyWallace更新指令总是先被解析,然后是来自调用句柄的指令。@benmarks这太愚蠢了:(好的,我想我需要一种替代方法来实现这一点,但我不知道如何实现。基本上,我需要一个次要句柄来优先于主布局handle@MartyWallace您只需在contacts_index_index_index中直接将page/2columns-right.phtml替换为page/1column.phtml即可,无需任何更新我知道这是可能的gh仅用于说明目的,并表明首先应用了更新标记。但我确实需要一个解决方案,直接替换根模板不是一个选项。它必须通过更新
<reference name="root">
    <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
    <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
</reference>