0

I have edited XML files to add an icon before the My Cart top-link. I made the icon a link as well, but I added a simple ....

I am looking to instead use Magento's variable that holds My Cart's URL in case my store's URL changes.

I am looking for something like this:

<a href="<?php $_myCartLink ?>">...</a>

with the correct My Cart Link variable.

Thank you!

$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"', '<a href="<?php echo Mage::getUrl('checkout/cart');?>"><i class="icon-shopping-cart"></i> </a>');
1

The line you are looking for is

$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"', '<a href="'.Mage::getUrl('checkout/cart').'"><i class="icon-shopping-cart"></i> </a>');

...I think

  • You have saved me three times today my friend! – Raphael Rafatpanah Apr 16 '13 at 22:07
  • What exactly does the '. and .' do? – Raphael Rafatpanah Apr 16 '13 at 22:08
  • 1
    The dot is used to concatenate strings. It's basic PHP. – Marius Apr 16 '13 at 22:09
  • I'm still very new to Object Oriented languages but I trying my best to learn as I go! Thanks for your help, today is turning out to be a great day! – Raphael Rafatpanah Apr 16 '13 at 22:21
2

To get a url from the frontend phtml file (which your example seems to be hinting at):

<?php echo Mage::getUrl('checkout/cart');?>

If you want to get the url from a controller use:

$this->getUrl('checkout/cart')

  • Please see my edit above for reference. I tried your first example in my local Links.php file but I get an error: unexpected T_STRING. Any ideas? – Raphael Rafatpanah Apr 16 '13 at 22:00
  • The problem is with the quotes! – Raphael Rafatpanah Apr 16 '13 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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