xml 在Magento中添加自定义活动链接到客户帐户导航

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 在Magento中添加自定义活动链接到客户帐户导航相关的知识,希望对你有一定的参考价值。

<?php
class  My_ModuleBlock_Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation
{

    /**
     * Is there a specific active link?
     *
     * @var
     */
    protected $_activeLink;

    /**
     * Set active link to this navigation
     *
     * @param string $linkName
     */
    public function setActiveLink($linkName)
    {
        $this->_activeLink = $linkName;
    }


    /**
     * Overloaded in order to force link active display
     * when there is an active link explicity set
     *
     * @param string $link
     * @return bool
     */
    public function isActive($link)
    {
        $isActive = parent::isActive($link);

        if(!$isActive && $link->getName() == $this->_activeLink) {
            $isActive = true;
        }

        return $isActive;
    }

}
?>
<sales_order_view>
    <reference name="my_customer_account_navigation">
        <action method="setActiveLink"><name>orders</name></action>
    </reference>
</sales_order_view>
<customer_account>

    <reference name="left">

        <!-- Remove existing navigation -->
        <action method="unsetChild"><name>customer_account_navigation</name></action>

        <!-- Build our own navigation -->
        <block type="my_module/customer_account_navigation" name="my_customer_account_navigation" before="-"
               template="customer/account/navigation.phtml">
            <action method="addLink" translate="label" module="customer">
                <name>account</name>
                <path>customer/account/</path>
                <label>My Account</label>
            </action>
            <action method="addLink" translate="label" module="customer">
                <name>account_edit</name>
                <path>customer/account/edit/</path>
                <label>My Account Information</label>
            </action>
            <action method="addLink" translate="label" module="customer">
                <name>address_book</name>
                <path>customer/address/</path>
                <label>My Address Book</label>
            </action>
            <action method="addLink" translate="label" module="sales">
                <name>orders</name>
                <path>sales/order/history/</path>
                <label>My Orders</label>
            </action>
        </block>

    </reference>

</customer_account>

以上是关于xml 在Magento中添加自定义活动链接到客户帐户导航的主要内容,如果未能解决你的问题,请参考以下文章

Magento在admin中将自定义输入字段添加到客户帐户窗体

Magento-将自定义字段添加到客户配置文件

使用自定义文本将项目添加到 Magento 购物车

Magento - 将所见即所得编辑器添加到自定义小部件

Magento 2:在 head 标签之后添加自定义脚本

将“添加到购物车”按钮重定向到 Magento 中的不同自定义页面/在 Magento 的产品页面中添加新按钮