1

How can I use a variable in the follow href element:

Example, instead of https://mag.outdoorequipped.com/ I like to use a variable. But I do not know how to get it in Magento.

Kindly Simon

4

2 Answers 2

1

Magento has handy helpers so that you don't need to hard code the links. You can use the following to go to mag.outdoorequipped.com/active in a phtml file:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . '/active'

or in a cms block:

{{store url="/active"}}

In phtml files

  1. Get Base Url : Mage::getBaseUrl();
  2. Get Skin Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
  3. Get Media Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
  4. Get Js Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
  5. Get Store Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
  6. Get Current Url Mage::helper('core/url')->getCurrentUrl();

In cms pages or static blocks

  1. Get Base Url : {{store url=""}}
  2. Get Skin Url : {{skin url='images/imagename.jpg'}}
  3. Get Media Url : {{media url='/imagename.jpg'}}
  4. Get Store Url : {{store url='mypage.html'}}
6
  • Okay, I see, so I have my html code at the moment under categories, then "Menu". And there I have my html code... I can put there instead html code a static block? Oct 7, 2015 at 8:43
  • correct so inside your static block add {{store url="/active"}} which should give you the correct url
    – rob3000
    Oct 7, 2015 at 8:47
  • So if I like to have in my href="mag.outdoorequipped.com/active/brands/asics.html" I need to do in the static block: href="{{store url="/active"}}/brands/asics.html" ? Oct 7, 2015 at 8:50
  • then it would need to be {{store url="/active/brands/asics"}} magento will work out the rest but just double check first.
    – rob3000
    Oct 7, 2015 at 8:52
  • okay, I see, will test it later. Where I need it is here: mag.outdoorequipped.com/active And then in the navigation menu I have under "Brands" 6 images with links. Oct 7, 2015 at 8:53
1

I did as followed and it works for me nice:

    <div class="row">
<div class="col-sm-2"><a href="{{store direct_url="brands/clarks.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/clarks.jpg"}}" /></a></div>
<div class="col-sm-2"><a href="{{store direct_url="brands/dr-martens.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/drmartens.jpg"}}" /></a></div>
<div class="col-sm-2"><a href="{{store direct_url="brands/kenneth-cole.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/kennethcole.jpg"}}" /></a></div>
<div class="col-sm-2"><a href="{{store direct_url="brands/royal-robbins.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/royalrobbins.jpg"}}" /></a></div>
<div class="col-sm-2"><a href="{{store direct_url="brands/sebago.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/sebago.jpg"}}" /></a></div>
<div class="col-sm-2"><a href="{{store direct_url="brands/gh-bass.html"}}"><img alt="" src="{{media url="wysiwyg/menulogo/fashion/ghbass.jpg"}}" /></a></div>

Your Answer

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

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