问题描述
我正在运行Mage 1.5.0.1,并且试图从我的帐户"部分删除导航链接.
I am running Mage 1.5.0.1 and I am trying to remove the navigation links from the My Account section.
我的local.xml具有以下功能:
My local.xml has the following which works fine:
<customer_account>
<reference name="root">
<action method="setTemplate"><template>page/staticpage.phtml</template></action>
</reference>
<reference name="left">
<remove name="cart_sidebar" />
<remove name="catalog.compare.sidebar" />
</reference>
</customer_account>
当我尝试添加以下代码时,系统会抛出错误:
When I try to add the following code the system throws and error:
<reference name="customer_account_navigation">
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
</reference>
错误
Invalid method Mage_Customer_Block_Account_Navigation::removeLinkByName
我在1.4中看到了此功能,是否不再支持该功能,或者我做错了什么?
I saw this function in 1.4, is it not supported anymore or am I doing something wrong?
推荐答案
我有一个类似的问题,我不想注释掉addLink节点,因为我们只想在local.xml中实现我们的更改.最终编写了一个小模块来做到这一点:
I had a similar problem, and I didn't want to comment out addLink node because we want to implement our changes in local.xml only. Ended up writing a small module to do it:
app \ etc \ modules \ Stackoverflow_Customerlinks.xml:
app\etc\modules\Stackoverflow_Customerlinks.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Stackoverflow_Customerlinks>
<active>true</active>
<codePool>local</codePool>
</Stackoverflow_Customerlinks>
</modules>
</config>
app \ code \ local \ Stackoverflow \ Customerlinks \ Block \ Account \ Navigation.php:
app\code\local\Stackoverflow\Customerlinks\Block\Account\Navigation.php:
<?php
class Stackoverflow_Customerlinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {
public function removeLinkByName($name) {
unset($this->_links[$name]);
}
}
app \ code \ local \ Stackoverflow \ Customerlinks \ etc \ config.xml:
app\code\local\Stackoverflow\Customerlinks\etc\config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<blocks>
<customer>
<rewrite>
<account_navigation>Stackoverflow_Customerlinks_Block_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
</global>
</config>
之后,您只需通过local.xml进行更改:
After that, you can simply make the changes through local.xml:
<customer_account>
<reference name="customer_account_navigation">
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
</reference>
</customer_account>
玩得开心:)
这篇关于从我的帐户中删除导航链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!