Magento覆盖布局文件会导致重写布局重复

时间:2013-06-06 14:42:12

标签: xml magento layout

好的,所以我试图覆盖另一个扩展的布局文件。我正在使用Magento Enterprise 1.13

这是我的config.xml:

<config>
    <frontend>
        <layout>
            <updates>
                <mymodule>
                    <file>mymodule.xml</file>
                </mymodule>
            </updates>
        </layout>
    </frontend>
</config>

然后在design / frontend / enterprise / mytheme / layout / mymodule.xml中:

<?xml version="1.0"?>
<layout version="0.1.0">       
    <affiliateplus_default>
        <update handle="page_two_columns_left" />
        <reference name="left">
            <block type="affiliateplus/account_navigation" before="-" name="account_navigator" template="affiliateplus/navigation.phtml">
                <action method="setNavigationTitle">
                    <title helper="affiliateplus/account/getNavigationLabel" />
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>balance</name>
                    <path>affiliateplus/inddsafdsex/paymentForm</path>
                    <label helper="affiliateplus/account/getBalanceLabel" />
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>6</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>home</name>
                    <path>affiliateplus</path>
                    <label>Affiliate Home</label>
                    <disabled>0</disabled>
                    <order>10</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>login</name>
                    <path>affiliateplus/account/login</path>
                    <label>Login</label>
                    <disabled helper="affiliateplus/account/customerLoggedIn" />
                    <order>20</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>register</name>
                    <path>affiliateplus/account/register</path>
                    <label>Signup</label>
                    <disabled helper="affiliateplus/account/isRegistered" />
                    <order>30</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>banners</name>
                    <path>affiliateplus/banner/list</path>
                    <label><![CDATA[Banners & Links]]>
                    </label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>40</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>refers</name>
                    <path>affiliateplus/refer/index</path>
                    <label><![CDATA[Refer Friends]]>
                    </label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>43</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>materials</name>
                    <path>affiliateplus/index/materials</path>
                    <label>Materials</label>
                    <disabled helper="affiliateplus/config/disableMaterials" />
                    <order>100</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>sales</name>
                    <path>affiliateplus/index/listTransaction</path>
                    <label>Commissions</label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>110</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>payments</name>
                    <path>affiliateplus/index/payments</path>
                    <label>Withdrawals</label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>120</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>referrers</name>
                    <path>affiliateplus/index/referrers</path>
                    <label>Traffics</label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>180</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>edit</name>
                    <path>affiliateplus/account/edit</path>
                    <label>Settings</label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>190</order>
                </action>
                <action method="addLink" translate="label" module="affiliateplus">
                    <name>logout</name>
                    <path>affiliateplus/account/logout</path>
                    <label>Logout</label>
                    <disabled helper="affiliateplus/account/accountNotLogin" />
                    <order>200</order>
                </action>
            </block>
        </reference>
    </affiliateplus_default>    
</layout>

然而,当我刷新页面时,我得到两个导航窗格。起初我以为我只是附加到已经存在的那个。但是,当我在我做出改变时,它会出现在两者中。我能想到的就是它正在拉动我的布局......然后拉出他们的布局并看到我的覆盖并再次拉入我的布局。就个人而言,这是我第一次尝试这样做,所以我很可能做错了,但我找不到任何帮助。感谢您提供任何帮助/意见。

1 个答案:

答案 0 :(得分:0)

我找到了答案:

我的真实问题是我对参考和块知之甚少。

我的技术问题是我引用了一个块,然后创建了一个名称不同的新块。 “左”块还包含导航栏的一个版本。这导致了重复的菜单。

我的最终代码如下:

    <affiliateplus_default>

        <block type="affiliateplus/account_navigation" before="-" name="account_navigator" template="affiliateplus/navigation.phtml">
            <action method="setNavigationTitle">
                <title helper="affiliateplus/account/getNavigationLabel" />
            </action>
            <action method="addLink" translate="label" module="affiliateplus">
                <name>balance</name>
                <path>affiliateplus/inddsafdsex/paymentForm</path>
                <label helper="affiliateplus/account/getBalanceLabel" />
                <disabled helper="affiliateplus/account/accountNotLogin" />
                <order>6</order>
            </action>

            ......

    </affiliateplus_default>

如果我只想添加链接而不是完全覆盖整个块,我可以完成以下操作:

    <affiliateplus_default>
      <reference="account_navigator">
        <action method="addLink" translate="label" module="affiliateplusext">
            [Link attributes]
        </action>
      </reference>
    </affiliateplus_default>

我希望这可以帮助刚开始的其他人。谢谢!