Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

Magento 2我的帐户菜单/导航链接:添加,删除,重新排序自定义链接

管理导航链接对商店的网站至关重要,因为它会对您的SEO产生重大影响。因此,在这篇文章中,我将指导您添加,重新排序和删除“定制链接”的方法

  • 步骤1:建立customer_account.xml
  • 步骤2:管理自定义链接
    • 添加自定义链接
    • 重新排序链接
    • 删除链接

步骤1:建立customer_account.xml

在添加,删除或重新排序链接之前,您要做的第一件事是在主题中创建customer_account.xml。请遵循以下指示:

app/design/frontend/mageplaza/mytheme/Magento_Customer/layout/customer_account.xml

步骤2:管理自定义链接

添加自定义链接

要添加新的自定义链接,只需复制以下代码:

<referenceBlock name="customer_account_navigation">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-custom-link" after="-" >
         <arguments>
             <argument name="label" xsi:type="string" translate="true">My Label</argument>
             <argument name="path" xsi:type="string">my-path</argument>
         </arguments>
    </block>
</referenceBlock>

然后将其添加到您的layout xml文件中。记住要自定义链接标签和路径

重新排序链接

要更改链接的顺序,您需要将元素从其原始位置移开并放回原处。并要求Magento 2将其同时放置在您想要的链接之后或之前。

<move element="YOUR_ELEMENT_NAME" destination="customer_account_navigation" after="YOUR_NEW_PLACE" />

在这种情况下,我将通过一个示例将My Wish List菜单项移动到以下位置My Orders

<!-- eg. "My Wish List" move after "My Orders" -->
<move element="customer-account-navigation-wish-list-link" destination="customer_account_navigation" after="customer-account-navigation-orders-link" />

在“订购链接”菜单项之前

<!-- eg. "My Wish List" move before "My Orders" -->
<move element="customer-account-navigation-wish-list-link" destination="customer_account_navigation" after="customer-account-navigation-orders-link" />

删除连结

为了简化操作,下面的示例向您展示了一次删除导航中所有链接的方法。

删除语法:

<referenceBlock name="block-name-here" remove="true"/>

以下是常见块名称的列表:

- customer-account-navigation-customer-balance-link : Store credit 
- customer-account-navigation-downloadable-products-link : Downloadable product link 
- customer-account-navigation-newsletter-subscriptions-link : Subscription link 
- customer-account-navigation-billing-agreements-link : Billing agreement link 
- customer-account-navigation-product-reviews-link : Product review link 
- customer-account-navigation-my-credit-cards-link : My credit card link 
- customer-account-navigation-account-link : Account link 
- customer-account-navigation-account-edit-link : Account edit link 
- customer-account-navigation-address-link : Address link 
- customer-account-navigation-orders-link : Orders link 
- customer-account-navigation-wish-list-link : Wish list link 
- customer-account-navigation-gift-card-link : Gift card link 
- customer-account-navigation-giftregistry-link : Gift registry 
- customer-account-navigation-reward-link : Reward points 
- customer-account-navigation-checkout-sku-link : Order by SKU

结论

简而言之,以上是有关如何在帐户信息中心中添加,删除,重新排序导航链接的最简单说明。我希望本文可以帮助您有效地管理自定义链接

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论