开发者

Removing links from top menu using local.xml

开发者 https://www.devze.com 2023-04-13 05:44 出处:网络
Does anyone know how I can remove links from the top menu using local.xml. In the default checkout.xml there is:

Does anyone know how I can remove links from the top menu using local.xml.

In the default checkout.xml there is:

<reference name="top.links">
    <block type="checkout/links" name="checkout_cart_link">
        <action method="addCartLink"></action>
        <action method="addCheckoutLink"></action>
    </block>
</reference>

And I would like to remove the addCartLink from the top menu. One way would be just edit the checkout.xml file, but it thi开发者_StackOverflow社区nk it would be a much better solution just to add the remove to my local.xml file, but I can't seem to get the right name to remove. If I do a

<layout>
    <default>
        <remove name="top.links" />
    </default>
</layout>

That does remove the entire menu, but how do I remove just a single item from the menu using locale.xml?

I am using Magento 1.6


You can do this in local.xml:

<default>
  <reference name="top.links"> 
    <action method="removeLinkByUrl">
      <url helper="checkout/url/getCartUrl" />
    </action> 
  </reference>
</default>

It was also my question How can i get the full path in local.xml file


<default>
 <reference name="top.links">
    <block type="wishlist/links" name="wishlist_link"/>
    <action method="removeLinkBlock"><blockName>wishlist_link</blockName></action>
 </reference> 
</default>

Add this part to your local.xml. Writing this under default will remove it from every page. So adjust it accordingly. I hope this will help you.


It should be:

<layout>
     <default>
        <reference name="top.links">
            <reference name="checkout_cart_link">
                <remove name="top-link-cart" />
            </reference>
        </reference>
     </default>
</layout>

But you can always copy the checkout.xml in your local theme and edit it.


<default>
<reference name="top.links">
    <remove name="wishlist_link"/>
</reference>
</default>

Add this part to your local.xml. That works for me. Just use "remove". That's it.


You can remove a link via layout update either

  1. by its name | calling removeLinkBlock($blockName)
  2. by its url | calling removeLinkByUrl($url)
  3. overwriting the file were it was added

The functions live in Mage_Page_Block_Template_Links

Option 1

The removeLinkByUrl() function needs an url as parameter which will usually provided by a helper function in the respective extension. Just grab it there and you can use something like

<reference name="top.links">
      <action method="removeLinkByUrl"><url helper="customer/getRegisterUrl"/></action>
   </reference>

In above case customer is the extensions name while getRegisterUrl is the function in the helper class.

If your extension isn't providing any function which is returning a link you can try following

<reference name="top.links">
   <action method="removeLinkByUrl"><url>ADD_THE_DYNAMIC_LINK_HERE</url></action>
</reference>

Option 2

If the link was added with a name, like

<reference name="top.links">
   <block type="wishlist/links" name="wishlist_link" />
   <action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>

you can just use

<reference name="top.links">
   <remove name="wishlist_link"/>
</reference>

or

<default>
 <reference name="top.links">
    <block type="wishlist/links" name="wishlist_link"/>
    <action method="removeLinkBlock"><blockName>wishlist_link</blockName></action>
 </reference> 
</default>

Option 3

If your link wasn't added with a name and a hardcoded url doesn't work for some reason you can just go ahead and copy the modules layout.xml to your custom theme folder and remove the lines where the link was added.


Hi This removes both the cart and checkout links from top.links in 1.9.3

<reference name="top.links"> 
  <action method="removeLinkByUrl">
    <url helper="checkout/url/getCartUrl" />
  </action>
  <action method="removeLinkByUrl">
    <url helper="checkout/url/getCheckoutUrl" />
  </action>
</reference>

based on the best accepted answer above but just in case anyone wants to remove both

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号