我想使用 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 - 使用 local.xml 更改或重新排列 Magento 登录和注销(顶部链接)位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11271194/