Get Url in phtml files

1. Get Base Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(); [/php]

2. Get Skin Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); [/php]

(a) Unsecure Skin Url :

If you need to get the skin url, the most common place you’d need to get it is from within a template file. If that is the case for you, this is how you can do it:

[php toolbar=”false” classname=”one_line”] $this->getSkinUrl(‘images/imagename.jpg’); [/php]

But, if you don’t happen to be within a template file where $this is not available, there is another way to do it (which actually $this->getSkinUrl() does anyway):

[php toolbar=”false” classname=”one_line”] Mage::getDesign()->getSkinUrl(‘images/your-image.jpg’); [/php]

(b) Secure Skin Url :

[php toolbar=”false” classname=”one_line”] $this->getSkinUrl(‘images/imagename.gif’, array(‘_secure’=>true));[/php]

3. Get Media Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);[/php]

4. Get Js Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);[/php]

5. Get Store Url :

[php toolbar=”false” classname=”one_line”] Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);[/php]

6. Get Current Url :

[php toolbar=”false” classname=”one_line”] Mage::helper(‘core/url’)->getCurrentUrl();[/php]

Get Url in cms pages or static blocks

1. Get Base Url :

[php toolbar=”false” classname=”one_line”] {{store url=""}} [/php]

2. Get Skin Url :

[php toolbar=”false” classname=”one_line”] {{skin url=’images/imagename.jpg’}} [/php]

3. Get Media Url :

[php toolbar=”false” classname=”one_line”] {{media url=’/imagename.jpg’}} [/php]

4. Get Store Url :

[php toolbar=”false” classname=”one_line”] {{store url=’mypage.html’}} [/php]

Leave A Comment