I want to put the Cart link at the end of the top links - ideally using my local.xml file.

Most top links are added like this:

<reference name="top.links">
      <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>

where I can obviously change the position.

But the cart links seem to be added like this:

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

How do I change the position of a link that doesn't use the addLink method?

2 Answers 2


The position is hardcoded in /app/code/core/Mage/Checkout/Block/Links.php:

$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');

The cart is pos 50 and the checkout link is pos 60. So maybe the easiest way is to position all top.links below 50. But to place just the cart link at the end you would have to rewrite the addCartLink() method.

  • Perfect - so obvious now that you point it out. Jul 11, 2013 at 11:11

Another way of doing it is by creating a small module (available here: https://github.com/digitalpianism/easytoplinks)


<?xml version="1.0"?>


<?xml version="1.0" encoding="UTF-8"?>



 * Class DigitalPianism_EasyToplinks_Block_Page_Template_Links
class DigitalPianism_EasyToplinks_Block_Page_Template_Links extends Mage_Page_Block_Template_Links

     * Change the position of an existing to make the layout customization easier
     * @param string $url
     * @param int $position
     * @return $this
    public function setPosition($url, $position)
        // Get the link and delete it from the current position
        foreach ($this->_links as $k => $v) {
            if ($v->getUrl() == $url) {
                $link = $this->_links[$k];

        if (isset($link)) {
            // Add link to new position
            $this->_addIntoPosition($link, $position);

        return $this;

Now that you have this module you can change the position easily via the layout by using:

<reference name="top.links">
    <action method="setPosition">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.