使用local.xml更改或重新排列Magento登录和注销(顶部链接)位置

前端之家收集整理的这篇文章主要介绍了使用local.xml更改或重新排列Magento登录和注销(顶部链接)位置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用local.xml重新排列我的顶级链接 – 特别是登录/注销链接.这是否可以在不删除链接然后重新添加它们并修改其位置标记的情况下实现?

当前(默认情况下)登录和注销在customer.xml中设置为位置100:

<customer_logged_in>
    <reference name="top.links">
        <action method="addLink" translate="label title" module="customer">
            <label>Log Out</label>
            <url helper="customer/getlogoutUrl"/>
            <title>Log Out</title>
            <prepare/>
            <urlParams/>
            <position>100</position>
        </action>
    </reference>
</customer_logged_in>

<customer_logged_out>
    <reference name="top.links">
        <action method="addLink" translate="label title" module="customer">
            <label>Log In</label>
            <url helper="customer/getLoginUrl"/>
            <title>Log In</title>
            <prepare/>
            <urlParams/>
            <position>100</position>
        </action>
    </reference>
</customer_logged_out>

我希望他们都在位置1(通过local.xml).

我知道setAttribute操作方法,但我不确定如何在这种情况下使用它.

解决方法

我没有找到一种更有效的方法在local.xml中执行此操作,因此我删除链接并使用修改后的位置参数重新添加它们:

<customer_logged_in>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getlogoutUrl"/></action>
        <action method="addLink" translate="label title" module="customer">
            <label>Log Out</label>
            <url helper="customer/getlogoutUrl"/>
            <title>Log Out</title>
            <prepare/>
            <urlParams/>
            <position>4</position>
            <liParams>id="top-logout"</liParams>
            <aParams/>
        </action>
    </reference>
</customer_logged_in>

<customer_logged_out>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
        <action method="addLink" translate="label title" module="customer">
            <label>Log In</label>
            <url helper="customer/getLoginUrl"/>
            <title>Log In</title>
            <prepare/>
            <urlParams/>
            <position>4</position>
            <liParams>id="top-login"</liParams>
            <aParams/>
        </action>
    </reference>
</customer_logged_out>

猜你在找的XML相关文章