我正试图移除帐户导航中的链接。我看了一下customer/account/navigation.phtml模板。该模板通过$ this-> getLinks()获取链接。如何编辑getLinks()方法,以便我可以删除一些链接?Magento - 如何添加/删除我的帐户导航链接?
回答
您的问题的答案最终取决于您的问题。该导航中的链接通过不同的布局XML文件添加。以下是首先在layout/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>
其它菜单项在其他布局文件中定义。例如,评价模块使用layout/review.xml
来定义它的布局,并包含以下内容:
<customer_account>
<!-- Mage_Review -->
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
</reference>
</customer_account>
要删除此链接,只需注释掉或删除<action method=...>
标签和菜单项目将消失。如果您想一次查找所有菜单项,请使用您最喜欢的文件搜索并找到任何name="customer_account_navigation"
的实例,这是Magento用于该导航块的句柄。
这个解决方案的创建之前广泛采用的修改通过在local.xml中执行更新而无需触摸基本模板文件进行布局。修改基本模板文件当然是一个很大的禁忌,因为修改可能在Magento版本更改中丢失。 – 2012-04-17 13:48:49
(zlovelady的解决方案是正确的) – 2012-04-17 13:49:05
自由“[前端链接管理器](http://www.magentocommerce.com/magento-connect/MagePsycho/extension/7905/frontend_links_manager)”扩展可以让你做到这一点,除了“我的应用程序”,从控制面板。 – ehartwell 2013-03-17 14:51:19
此外,你需要做的config.xml中这样的事情,如果你正在开发一个定制的模块
<frontend>
<layout>
<updates>
<hpcustomer>
<file>hpcustomer.xml</file>
</hpcustomer>
</updates>
</layout>
</frontend>
如果你想选择删除链接,而无需复制/编辑整个XML文件,一个漂亮的解决方案可以在this post in the magento forums
发现在此解决方案,覆盖Mage_Customer_Block_Account_Navigation
块与本地版本,增加了一个removeLinkByName
方法,然后您可以在您的layout.xml
文件中使用,就像这样:
<?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>
</reference>
</customer_account>
</layout>
这就是论坛,其解决方案是有效的,请注明那么,如果u能 – 2014-10-20 08:38:24
瑞安Christofferson了更好的答案,谢谢 – 2014-11-07 10:55:45
@PratikCJoshi看到http://stackoverflow.com/a/5976641/794071 – 2015-10-09 06:55:31
技术上zlovelady的答案是可取的,但因为我以前只从导航删除项目,在模板取消设置的不需要的导航项目的方法对我来说是最快/最简单的方法:
只是重复
app/design/frontend/base/default/template/customer/account/navigation
到
app/design/frontend/YOUR_THEME/default/template/customer/account/navigation
和取消不需要的导航项目之前得到呈现,如:
<?php $_links = $this->getLinks(); ?>
<?php
unset($_links['recurring_profiles']);
?>
+1最好的选择是不修改核心文件,并把它放在一个地方 – 2012-07-31 23:17:58
您还可以通过后端禁用菜单项,而无需触摸任何代码。进入:
System > Configuration > Advanced
您将看到一长串选项。以下是一些关键模块设置为“已禁用”:
Mage_Downloadable -> My Downloadable Products
Mage_Newsletter -> My Newsletter
Mage_Review -> My Reviews
Mage_Tag -> My Tags
Mage_Wishlist -> My Wishlist
我也被禁用Mage_Poll,因为它在其他页面模板,显示了一个趋势,如果你不使用它可以是恼人。
以去除在Magento我的帐户面板中的任何链接的最简单方法是先复制:
应用程序/设计/前端/基/默认/模板/客户/帐号/ navigation.phtml
到
应用程序/设计/前端/企业/ YOURSITE /模板/客户/帐号/ navigation.phtml
打开该文件,并罚款这一行,它应该在第34行:
<?php $_index = 1; ?>
右键下方补充一点:
<?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
unset($_links['tags']); /* My Tags */
unset($_links['invitations']); /* My Invitations */
unset($_links['enterprise_customerbalance']); /* Store Credit */
unset($_links['OAuth Customer Tokens']); /* My Applications */
unset($_links['enterprise_reward']); /* Reward Points */
unset($_links['giftregistry']); /* Gift Registry */
unset($_links['downloadable_products']); /* My Downloadable Products */
unset($_links['recurring_profiles']); /* Recurring Profiles */
unset($_links['billing_agreements']); /* Billing Agreements */
unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
?>
只是删除任何这里的链接,你希望出现的。
大部分上述工作,但对我来说,这是最简单的。
安装插件,注销,登录系统高级前端链接管理器,选中并取消选中要显示的选项。它也适用于您网站上的任何前端导航。
http://www.magentocommerce.com/magento-connect/frontend-links-manager.html
使用起来非常简单。 – 2014-03-04 17:49:03
其工作100%,我相信。
第1步:进入(YourTemplate /客户/帐号/ navigation.phtml)
步骤2:替换该行:<?php $_count = count($_links); ?>
带:
<?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
unset($_links['account']); /* Account Info */
unset($_links['account_edit']); /* Account Info */
unset($_links['tags']); /* My Tags */
unset($_links['invitations']); /* My Invitations */
unset($_links['reviews']); /* Reviews */
unset($_links['wishlist']); /* Wishlist */
unset($_links['newsletter']); /* Newsletter */
unset($_links['orders']); /* My Orders */
unset($_links['address_book']); /* Address */
unset($_links['enterprise_customerbalance']); /* Store Credit */
unset($_links['OAuth Customer Tokens']); /* My Applications */
unset($_links['enterprise_reward']); /* Reward Points */
unset($_links['giftregistry']); /* Gift Registry */
unset($_links['downloadable_products']); /* My Downloadable Products */
unset($_links['recurring_profiles']); /* Recurring Profiles */
unset($_links['billing_agreements']); /* Billing Agreements */
unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
>
你可以也可以使用这个免费的即插即用扩展:
http://www.magentocommerce.com/magento-connect/manage-customer-account-menu.html
此扩展程序不会触及任何Magento核心文件。
有了这个扩展,你可以:每个菜单项
- 决定显示或在Magento的后端点击隐藏它。
- 轻松重命名菜单项。
我的解决办法,完全除去块和那个local.xml与我所需要的块创建它,所以,例如
<customer_account>
<reference name="left">
<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>
</reference>
</customer_account>
打开导航。PHTML
app/design/frontend/yourtheme/default/template/customer/account/navigation.phtml
与您要删除
<?php
$_count = count($_links);
unset($_links['account']); // Account Information
unset($_links['account_edit']); // Account Information
unset($_links['address_book']); // Address Book
unset($_links['orders']); // My Orders
unset($_links['billing_agreements']); // Billing Agreements
unset($_links['recurring_profiles']); // Recurring Profiles
unset($_links['reviews']); // My Product Reviews
unset($_links['wishlist']); // My Wishlist
unset($_links['OAuth Customer Tokens']); // My Applications
unset($_links['newsletter']); // Newsletter Subscriptions
unset($_links['downloadable_products']); // My Downloadable Products
unset($_links['tags']); // My Tags
unset($_links['invitations']); // My Invitations
unset($_links['enterprise_customerbalance']); // Store Credit
unset($_links['enterprise_reward']); // Reward Points
unset($_links['giftregistry']); // Gift Registry
unset($_links['enterprise_giftcardaccount']); // Gift Card Link
?>
- 1. Magento - 在主菜单中添加到我的帐户的链接导航栏
- 2. 在Magento客户帐户导航上使用jQuery Block UI。链接
- 3. 如何将活动类添加到magento中的导航链接?
- 4. Magento“我的帐户”链接部分
- 5. 如何删除Magento中的“我的购物车”和“结帐”菜单链接?
- 6. OpenCart 2.1.0.2删除帐户链接
- 7. 如何从链接添加/删除类
- 8. magento - 添加链接页脚,但不是顶部导航菜单
- 9. 在Magento中添加静态链接到顶部导航菜单
- 10. 导航栏的JQuery添加/删除类
- 11. 如何删除我的bluemix帐户ID?
- 12. 如何删除每个页面上的主页导航链接?
- 13. Magento中隐藏左侧导航栏但显示帐户控制面板链接
- 14. Magento 1.9导航到首页的链接
- 15. 如何确保引导导航栏链接有当添加
- 16. magento删除我的账户
- 17. 添加活动状态到用户滚动的链接导航
- 18. 如何从本地机器删除git帐户并添加新帐户
- 19. 无法将实体链接API添加到我的Azure帐户
- 20. 如何在顶部添加导航栏的URL链接
- 21. Magento自定义扩展要显示我的帐户链接
- 22. 如何将文本链接添加到下拉导航
- 23. 如何使用zend导航在链接中添加accesskey属性
- 24. 如何查找链接名称以从“我的帐户”页面中删除链接?
- 25. 链接帐户
- 26. 如何将活动类添加到我的导航链接React路由器?
- 27. 添加删除链接,嵌套属性
- 28. 链接列表,值,添加和删除
- 29. 如何在用户添加或删除帐户后获取加载项中Outlook帐户的实际列表?
- 30. Magento:如何将顶部链接移动到导航区块?
自由“[前端链接管理器](http://www.magentocommerce.com/magento未设置链接替换
-connect/MagePsycho/extension/7905/frontend_links_manager)'扩展程序可让您从控制面板执行此操作,除了“我的应用程序”。 – ehartwell 2013-03-17 14:38:11
非常好的细节和例子来帮助你在Mangeto添加和删除排名靠前的使用'local.xml'文件:http://www.classyllama.com/development/magento-development/editing-magentos-top-links-the - 更好的路 – 2012-05-12 15:16:40
您可以使用此模块:https://github.com/netz98/N98_LayoutHelper – Alex 2012-09-26 14:39:43