Magento designers : get URL code for beginners

This post help you to get url, directory path, to get module URL. This is very basic post, that will help to magento designers or beginners.

Get Url in phtml files

Get Base Url : http://localhost/magento/

echo Mage::getBaseUrl();

Get Skin Url : http://localhost/magento/skin/

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Unsecure Skin Url : http://localhost/magento/skin/frontend/base/default/images/imagename.jpg

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

Secure Skin Url : http://localhost/magento/skin/frontend/base/default/images/imagename.gif

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

Get Media Url : http://localhost/magento/media/

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Js Url : http://localhost/magento/js/

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

Get Store Url : http://localhost/magento/

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Current Url : http://localhost/magento/

echo Mage::helper('core/url')->getCurrentUrl();

Get Url in cms pages or static blocks

Get Base Url : http://localhost/magento/

{{store url=""}}

Get Skin Url : http://localhost/magento/skin/frontend/base/default/images/imagename.jpg

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

Get Media Url : http://localhost/magento/media/imagename.jpg

{{media url='imagename.jpg'}}

Get Store Url : http://localhost/magento/mypage.html

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

Published by Jayanti Solanki

Web development is my first love. Over the last 14+ years, I have developed an array of websites.

Leave a comment