magento add links in local xml


/ Published in: XML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?xml version="1.0"?>
  2. <layout version="0.1.0">
  3. <default>
  4. <reference name="root">
  5. <reference name="top.links">
  6. <!-- Add custom links. Pretty self-explanatory.
  7. Dig into app/code/core/Mage/Page/Block/Template/Links.php for more info -->
  8. <action method="addLink" translate="label title">
  9. <label>About Us</label>
  10. <url>about</url> <!-- can use full url also -->
  11. <title>About Us</title>
  12. <prepare>true</prepare> <!-- set true if adding base url param -->
  13. <urlParams helper="core/url/getHomeUrl"/> <!-- base url - thanks @Russ! -->
  14. <!-- there are a few param you can send to do different things in <urlParams>
  15. dig into app/code/core/Mage/Core/Model/Url.php, around line 803 -->
  16.  
  17. <!-- below adds #add-fragment to the end of your url -->
  18. <!-- <urlParams><_fragment>add-fragment</_fragment></urlParams> -->
  19.  
  20. <!-- below adds ?add-query to the end of your url -->
  21. <!-- <urlParams><_query>add-fragment</_query></urlParams> -->
  22.  
  23. <!-- below gives you a new session id (i think...)-->
  24. <!-- <urlParams><_nosid>true</_nosid></urlParams> -->
  25.  
  26. <!-- below replaces double quotes, single quotes, greater than, and less than signs
  27. to their respective url escaped replacements (%22, %27, %3E, %3C) -->
  28. <!-- <urlParams><_escape>i'm-a-blog-url</_escape></urlParams> -->
  29.  
  30. <position>1</position>
  31. <liParams/>
  32. <aParams>class="top-link-about-us"</aParams>
  33. <beforeText></beforeText>
  34. <afterText></afterText>
  35. </action>
  36.  
  37. <!-- Removes 'My Account' link - Default position: 10 -->
  38. <action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>
  39.  
  40. <!-- Removes 'Wishlist' link - Default position: 20 -->
  41. <!-- for Magento 1.3.x -->
  42. <action method="removeLinkByUrl"><url helper="wishlist/"/></action>
  43.  
  44. <!-- for Magento 1.4.x -->
  45. <remove name="wishlist_link"/>
  46.  
  47. <!-- Removes 'My Cart' AND 'Checkout' links
  48. Default position: 40 and 50 respectively -->
  49. <remove name="checkout_cart_link"/>
  50.  
  51. <!-- To re-add 'My Cart' or 'Checkout' after removing both -->
  52. <block type="checkout/links" name="checkout_cart_link_custom">
  53. <action method="addCartLink"></action>
  54. <action method="addCheckoutLink"></action>
  55. </block>
  56. </reference>
  57. </reference>
  58. </default>
  59.  
  60. <customer_logged_out>
  61. <!-- Removes 'Log In' link - Default position: 60 -->
  62. <reference name="top.links">
  63. <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
  64. </reference>
  65. </customer_logged_out>
  66.  
  67. <customer_logged_in>
  68. <!-- Removes 'Log Out' link - Default position: 60 -->
  69. <reference name="top.links">
  70. <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
  71. </reference>
  72. </customer_logged_in>
  73.  
  74. </layout>

URL: http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.