Magento - Editing the Pesky Top Links
To make sure we are talking about the ‘top links’ the file I am referring to is:
/app/design/frontend/default/template/page/template/links.phtml
I usually end up creating a new static block and replicating the links in there, so I get total control, and then I put the sidebar.phtml file up amongst the links.
However, you could add a class to the My Cart link by editing the links.phtml file and change the following line from:
<li
getIsFirst()||$_link->getIsLast()): ?>
to this:
getLabel()==’My Cart’) : ?>class=”my-cart”getIsFirst()||$_link->getIsLast()): ?>Note: I am using the Label ‘My Cart’, so if you change this via Translate CSV files it may no longer work – I have not tested this. The Translate Inline option seems to handle it OK.You could then use the Translate Inline option under System > Configuration > Developer: Translate Inline. Set this to Yes, then in the Frontend you will have little Edit book icons. Click on the one for My Carts and change it to:My Cart (1 item)
The problem with this is it gives a horrible mouseover title tag.
The alternative solution, to get around this, is edit a core file. Scary stuff.
Locate the following file, download it:
app/code/core/Mage/Checkout/Block/Links.php
then upload to:
app/code/local/Mage/Checkout/Block/Links.php
Then edit it so it looks like the following:
public function addCartLink() { $parentBlock = $this->getParentBlock(); if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) { $count = $this->getSummaryQty() ? $this->getSummaryQty() : $this->helper('checkout/cart')->getSummaryCount(); if ($count == 1) { $text = $this->__('My Cart (%s item)', $count); } elseif ($count > 0) { $text = $this->__('My Cart (%s items)', $count); } else { $text = $this->__('My Cart'); } $parentBlock->removeLinkByUrl($this->getUrl('checkout/cart')); $parentBlock->addLink($text, 'checkout/cart', 'My Cart', true, array(), 50, null, 'class="top-link-cart"'); } return $this; }
Notice: There is an edit in the line:
$parentBlock->addLink($text, ‘checkout/cart’, ‘My Cart’, true, array(), 50, null, ‘class=”top-link-cart”‘);
The second instance of $text has been changed to ‘My Cart’. This is the Title Tag label.
Does that do the trick? Not sure if it is easy-ish.