Magento là thêm liên kết ở customer account leftphía bên tay bằng cách sử dụng addLinkchức năng Mage_Customer_Block_Account_Navigationở đây
public function addLink($name, $path, $label, $urlParams=array())
{
$this->_links[$name] = new Varien_Object(array(
'name' => $name,
'path' => $path,
'label' => $label,
'url' => $this->getUrl($path, $urlParams),
));
return $this;
}
Magento thêm các liên kết bằng mã xml này
<action method="addLink" translate="label" module="customer"><name>account</name>
<path>customer/account/</path><label>Account Dashboard</label></action>
Quá trình dễ dàng nhất
có lot of layout xmltập tin nhưtag.xml,outh.xml,customer.xml,checkout.xml
là được bao gồm có link on left navigation using addLink function
.Nếu thư mục bố trí của bạn app/design/frontend/your package/your template/layout/ không có các tập tin nhưng nó links are availabletại của bạn account left navigationsau đó theo Magento fallback luận cần phải sao chép những từ app/design/frontend/base/default/layout/để app/design/frontend/your package/your template/layout/.
Sau đó nhận xét mã này các tập tin.
để đi layout xmls filetìm <action method="addLink"mã của bạn và loại bỏ các mã đó
Đúng quy trình sử dụng local.xml
Tạo một phương thức trên Mage_Customer_Block_Account_Navigationloại bỏ liên kết bằng cách sử dụng mã dưới đây
public function removeLink($removename)
{
unset($this->_links[$removename]);
return $this;
}
Bạn cần tạo một phần mở rộng cho cái này
Bước 1: Viết lại lớp Mage_Customer_Block_Account_Navigation bằng lớpAmit_RemoveNavigation_Block_Customer_Account_Navigation
Tạo tệp Navigation.php tại ứng dụng \ code \ local \ Amit \ RemoveNavulation \ Block \ Customer \ Account
<?php
class Amit_RemoveNavigation_Block_Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation
{
public function removeLink($removename)
{
unset($this->_links[$removename]);
return $this;
}
}
Bước2: tạo config.xmltại app\code\local\Amit\RemoveNavigation\etcvà
<?xml version="1.0"?>
<config>
<modules>
<Amit_RemoveNavigation>
<version>1.0.0</version>
</Amit_RemoveNavigation>
</modules>
<global>
<helpers>
<removenavigation>
<class>Amit_RemoveNavigation_Helper</class>
</removenavigation>
</helpers>
<blocks>
<removenavigation>
<class>Amit_RemoveNavigation_Block</class>
</removenavigation>
<customer>
<rewrite>
<account_navigation>Amit_RemoveNavigation_Block_Customer_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
</global>
</config>
Bước 3: tạo lớp trình trợ giúp cho mô-đun này Data.phptạipp\code\local\Amit\RemoveNavigation\Helper
<?php
class Amit_RemoveNavigation_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Bước 4: tạo tập tin điều khiển mô-đun Amit_RemoveNavigation.xmltạiapp/etc/modules/
<?xml version="1.0"?>
<config>
<modules>
<Amit_RemoveNavigation>
<active>true</active>
<codePool>local</codePool>
<version>1.0.0</version>
</Amit_RemoveNavigation>
</modules>
</config>
Bạn sẽ thấy tại outh.xml mã này
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="oauth">
<name>OAuth Customer Tokens</name>
<path>oauth/customer_token</path>
<label>My Applications</label>
</action>
</reference>
được thêm vào liên kết ứng dụng của tôi trên điều hướng bên trái
vì vậy hãy tạo ra local.xmltạiapp/design/frontend/your package/your template/layout/
thêm mã này
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="customer_account_navigation">
<action method="removeLink" translate="label" module="oauth">
<name>OAuth Customer Tokens</name> <!-- remove by name -->
</action>
</reference>
</layout>
Bạn sẽ thấy đoạn mã dưới đây tại downloadable.xml
<customer_account>
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="downloadable"><name>downloadable_products</name><path>downloadable/customer/products</path><label>My Downloadable Products</label></action>
</reference>
</customer_account>
Như tôi đã nói, tôi đã thêm xóa liên kết bằng thẻ, <name>downloadable_products</name>vì vậy hãy thêm mã local.xml tôi trông giống như
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="customer_account_navigation">
<action method="removeLink" translate="label" module="oauth">
<name>OAuth Customer Tokens</name> <!-- remove by name -->
</action>
<action method="removeLink" translate="label" module="oauth">
<name>downloadable_products</name> <!-- remove by name -->
</action>
</reference>
</layout>
Trong magento thêm điều này bởi
điều này theo logic của bạn
<name>recurring_profiles</name>
<name>billing_agreements</name>
<name>reviews</name>
<name>downloadable_products</name>
<name>OAuth Customer Tokens</name>
<name>account</name>
<name>account_edit</name>
<name>address_book</name>
<name>orders</name>
<name>tags</name>
<name>wishlist</name>
<name>newsletter</name>