In previous versions of Magento the top links, i.e.
* My Account
* My Wishlist
* My Cart
* Checkout
* Log Inwere called in:
/app/design/frontend/[interface_name]/[theme_name]/template/page/html/top.links.html
In this file, the $toplinks array was looped through and a list of links are echoed. The proper way to then add extra links to this array is by the addLink method in the appropriate layout file. As some of you will notice this is similar in fashion to the footer links as I described in a previous post.
The block that was used to define the toplink could be found in:
/app/code/core/Mage/Page/Block/Html/Toplinks.php
This has now been deprecated, and the toplinks now follow the more generic links template in:
app/code/core/Mage/Page/Block/Template/Links.php
So, if you were ever tempted to just hack an <li> element in the top links foreach loop, there’s no doing that any more you naughty girls and boys! Use Magento’s built in awesomness, that’s why it’s there!
As an example, in a recent /layout/page.xml file I had the code below to add “help” and “contact us” links.
<block type="page/template_links" name="top.links" as="topLinks"> <action method="addLink" translate="label title"><label>help</label><url>help</url><title>help</title><prepare/><urlParams/><position>100</position></action> <action method="addLink" translate="label title"><label>contact us</label><url>contacts</url><title>contact us</title><prepare/><urlParams/><position>10</position></action> </block>
Easy as pie.
Related posts:
Hi there,i wonder how to add a styled search box into the top links?Thanks…
Hi Handoyo. Assuming you still have the default search box in the header, the simplest way would be to move it with some extra css. Do you have something that I can look at?