Magento 从我的帐户中删除导航链接
我正在运行Mage 1.5.0.1,并试图从我的帐户部分删除导航链接 My local.xml具有以下功能,可以正常工作:Magento 从我的帐户中删除导航链接,magento,Magento,我正在运行Mage 1.5.0.1,并试图从我的帐户部分删除导航链接 My local.xml具有以下功能,可以正常工作: <customer_account> <reference name="root"> <action method="setTemplate"><template>page/staticpage.phtml</template></action> </refere
<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>
我在1.4中看到了这个函数,它不再受支持了,还是我做错了什么?还有其他各种各样的xml文件,它们引用了
,您可以将xml文件复制到布局目录,并注释掉addLink节点。除此之外,我看到了一个removeLinkByUrl,您可以尝试替代它。我遇到了类似的问题,我不想注释掉addLink节点,因为我们只想在local.xml中实现我们的更改。最后写了一个小模块来完成:
app\etc\modules\Stackoverflow\u 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:
<?php
class Stackoverflow_Customerlinks_Block_Account_Navigation extends Mage_Customer_Block_Account_Navigation {
public function removeLinkByName($name) {
unset($this->_links[$name]);
}
}
您可以使用:
<customer_account>
<action method="unsetChild"><name>customer_account_navigation</name></action>
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
...
</block>
</customer_account>
客户\帐户\导航
账户客户/账户/账户仪表板
账户\编辑客户/账户/编辑/账户信息
...
重写不是解决方案…我的帐户导航链接来自customer.xml文件
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
<action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
</block>
账户客户/账户/账户仪表板
账户\编辑客户/账户/编辑/账户信息
地址簿客户/地址/地址簿
只是告诉你们导航菜单中的所有链接。
要删除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>
<?xml version="1.0"?>
<layout version="0.1.0">
<customer_account>
<reference name="customer_account_navigation" >
<!-- remove the link using your custom method -->
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
<action method="removeLinkByName"><name>reviews</name></action>
<action method="removeLinkByName"><name>downloadable_products</name></action>
<action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>
<action method="removeLinkByName"><name>account</name></action>
<action method="removeLinkByName"><name>account_edit</name></action>
<action method="removeLinkByName"><name>address_book</name></action>
<action method="removeLinkByName"><name>orders</name></action>
<action method="removeLinkByName"><name>tags</name></action>
<action method="removeLinkByName"><name>wishlist</name></action>
<action method="removeLinkByName"><name>newsletter</name></action>
</reference>
</customer_account>
</layout>
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink"><name>tags</name></action>
<action method="addLink"><name>newsletter</name></action>
</reference>
</customer_account>
重复出现的用户配置文件
计费协议
评论
可下载的产品
OAuth客户代币
账户
帐户编辑
地址簿
命令
标签
愿望者
新闻稿
谢谢你的回答Daniel Sloof我的想法是利用css的强大功能,避免大量的代码修改
例如
显然,将选择器更改为您的主题客户导航li,并使用li:nth-child()sudo,在括号之间加上要删除的数字。
也可以在customer.xml中使用注释,以防您忘记6个月后所做的事情。您还可以通过空链接覆盖声明-不定义“path”和“label”,直接在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>
<?xml version="1.0"?>
<layout version="0.1.0">
<customer_account>
<reference name="customer_account_navigation" >
<!-- remove the link using your custom method -->
<action method="removeLinkByName"><name>recurring_profiles</name></action>
<action method="removeLinkByName"><name>billing_agreements</name></action>
<action method="removeLinkByName"><name>reviews</name></action>
<action method="removeLinkByName"><name>downloadable_products</name></action>
<action method="removeLinkByName"><name>OAuth Customer Tokens</name></action>
<action method="removeLinkByName"><name>account</name></action>
<action method="removeLinkByName"><name>account_edit</name></action>
<action method="removeLinkByName"><name>address_book</name></action>
<action method="removeLinkByName"><name>orders</name></action>
<action method="removeLinkByName"><name>tags</name></action>
<action method="removeLinkByName"><name>wishlist</name></action>
<action method="removeLinkByName"><name>newsletter</name></action>
</reference>
</customer_account>
</layout>
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink"><name>tags</name></action>
<action method="addLink"><name>newsletter</name></action>
</reference>
</customer_account>
标签
新闻稿
默认情况下,我们没有“removeLink”这样的方法。因此,诀窍是使用“unsetChild”方法删除整个块,并使用我们自己在local.xml中添加的链接将所需的链接块添加回来
<customer_account translate="label">
<reference name="left">
<!--Unset the whole block then add back later-->
<action method="unsetChild"><name>customer_account_navigation</name></action>
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
<action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
<action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
<action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
<action method="addLink" translate="label" module="sales"><name>orders</name><path>sales/order/history/</path><label>My Orders</label></action>
<action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
<action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Favorite</label></action>
<action method="addLink" translate="label" module="newsletter"><name>newsletter</name><path>newsletter/manage/</path><label>Newsletter Subscriptions</label></action>
</block>
<remove name="catalog.compare.sidebar"/>
</reference>
</customer_account>
客户\帐户\导航
账户客户/账户/账户仪表板
账户\编辑客户/账户/编辑/账户信息
地址簿客户/地址/地址簿
订单销售/订单/历史记录/我的订单
回顾回顾/客户我的产品回顾
愿望清单/我的最爱
时事通讯/管理/时事通讯订阅
我只是像以前一样重构了帐户仪表板链接并删除了CSS第n个子选择器,而是将app/design/frontend/default/your_theme/template/customer/account/navigation.phtml更改为此
<div class="block block-account">
<div class="block-title">
<strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
<ul>
<?php $_links = $this->getLinks(); ?>
<?php $_index = 1; ?>
<?php $_count = count($_links);
unset($_links['recurring_profiles']);
unset($_links['billing_agreements']);
unset($_links['reviews']);
unset($_links['tags']);
unset($_links['OAuth Customer Tokens']);
unset($_links['downloadable_products']);
?>
<?php foreach ($_links as $_link): ?>
<?php $_last = ($_index++ >= $_count); ?>
<?php if ($this->isActive($_link)): ?>
<li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
<?php else: ?>
<li<?php echo ($_last ? ' class="last"' : '') ?>><a href="<?php echo $_link->getUrl() ?>"><?php echo $_link->getLabel() ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
>
基本上取消所有不需要的链接。转到app/design/frontend/YourPackageName/YourThemeName/layout/
,创建一个sales/
目录(如果没有),然后创建一个名为billing\u agreement.xml
和recurrentical\u profile.xml
的空文件或目录
有史以来最干净的方法,没有自定义函数,没有CSS攻击,模板文件中没有逻辑
这对用户完全隐藏了计费协议和定期配置文件功能。此模块进行功能排序或显示我自己的链接,不进行布局,phtml覆盖块并生成所有逻辑
- 最干净的解决方案是覆盖框,并添加一个从布局中删除链接的方法
Huh-独立提出了相同的解决方案。。。或者,无论如何都要关门。我似乎无法删除“奖励积分”链接。也许我想不出它对目标的正确名称?似乎找不到它首先添加到哪里(查看sale.xml reward.xml…)有什么想法吗?“enterprise_reward”如果有人感兴趣……我求求你,你能指定将local.xml
放在哪里吗?Thanks@jQueryAngryBirdapp/design/frontend///layout/local。xml@DanielSloof嗨,为什么你不认为艾维夸给出了更好的答案?这是非常糟糕的做法!用css伪造它不是解决办法!这里面没有假货。与修补XML或PHP相比,我认为这是一个非常干净的解决方案。这绝不是任何Web开发人员都应该做的事情-也许链接会导致坏页面,并且会被机器人抓取-它的冗余标记和css代码-有更好的解决方案(layout.xml/block方法)-你有硬编码的子ID,这简直是胡说八道-当你称之为“干净的解决方案”时,你实际上不知道你在说什么我不想这么说,因为这是一个丑陋的解决方案,但尽管所有的XML答案对我都不起作用,但这确实起了作用。如果指定css使其仅适用于帐户框,则可以。顺便说一下,谷歌甚至不应该为注册用户的账户页面编制索引。此外,如果列表项被CSS隐藏,或者一开始就没有呈现出来,用户也不会分辨出区别
<div class="block block-account">
<div class="block-title">
<strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
<ul>
<?php $_links = $this->getLinks(); ?>
<?php $_index = 1; ?>
<?php $_count = count($_links);
unset($_links['recurring_profiles']);
unset($_links['billing_agreements']);
unset($_links['reviews']);
unset($_links['tags']);
unset($_links['OAuth Customer Tokens']);
unset($_links['downloadable_products']);
?>
<?php foreach ($_links as $_link): ?>
<?php $_last = ($_index++ >= $_count); ?>
<?php if ($this->isActive($_link)): ?>
<li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
<?php else: ?>
<li<?php echo ($_last ? ' class="last"' : '') ?>><a href="<?php echo $_link->getUrl() ?>"><?php echo $_link->getLabel() ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>