在洋红色中更改我的帐户页面中的导航顺序


Change the order of navigation in my account page in magento

我在帐户页面的前端的帐户页面中添加了新链接离线订单

它在导航中成功添加

但它显示在菜单中的最后一个

我想订单后添加离线订单链接

下面给出了我的代码,我在导航链接中添加链接

    <reference name="customer_account_navigation">
          <action method="addLink" translate="label" module="offorder"><name>offlineorders</name><path>offorder/offorder/history</path><label>My OfflineOrder</label></action>
    </reference>
</customer_account>

我必须做什么才能更改链接顺序?

没有"开箱即用"的方法可以做到这一点,除非您将代码放在所需链接正下方的sales.xml布局文件中。
这是因为处理客户帐户菜单的Mage_Customer_Block_Account_Navigation块无法对链接进行排序。请参阅添加链接的方法:

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;
}

还有另一种选择,可以覆盖上面提到的块,并在方法中 getLinks ,您可以安排第一个链接,而不是返回链接。但我不会去那里。

> <position>方法对我根本不起作用。

作为一种解决方法,我使用了<addLink>方法,其中帐户导航块首先填充链接

就我而言,那是在

<customer_account translate="label">
  <!-- -->
  <reference name="left">
     <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>My Account</label></action>
        <action method="addLink" translate="label" module="myModule"><name>myLInk</name><path>my/path/</path><label>My Link</label></action>
     </block>
  </reference>
  <!-- -->
</customer_account>

您可以通过更改 XML 中的数字来更改顺序

因此,如果您希望销售订单历史记录位于"我的仪表板"旁边,则需要将 220 更改为 240。它是 240,因为仪表板订单号是 250。

销售/订单/历史记录 订单历史 220

用于更改我的帐户中的导航顺序

例如,您要更改"我的帐户"链接,请转到布局>客户.xml

添加此行

<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>

这里的位置将定义您的链接排序顺序,您将不得不更改每个链接的位置,例如我的订单(为此您将不得不更改销售.xml)