10 Feb 2014

Magento : Get Base Url,Skin Url,Media Url,Js Url,Store Url and Current Url

There are different way to retrieve different URL paths depending in which section you’re editing.So Magento Mage Core, Admin Static Blocks, or Phtml edits are usually includes getting url path such images, javascript, base url, media and store url.Lets get the different URL on different location by following the below examples.

To Retrieve URL path in STATIC BLOCK
To get SKIN URL

{{skin url='images/jyoti.jpg'}}

To get Media URL

{{media url='/jyoti.jpg'}}

To get Store URL

{{store url='mypage.html'}}

To get Base URL

{{base url='yourstore/mypage.html'}}


TO Retrieve URL path in PHTML Note: In editing PHTML don't forget to enclode the following code with PHP tag Not secure Skin URL:

echo $this->getSkinUrl('images/jyoti.jpg')

Secure Skin URL

echo $this->getSkinUrl('images/jyoti.gif', array('_secure'=>true))

Get Current URL

$current_url = Mage::helper('core/url')->getCurrentUrl();

Get Home URL

$home_url = Mage::helper('core/url')->getHomeUrl();


Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);


Get Magento Media Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

Get Base Url :

Mage::getBaseUrl();