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

I’m a web developer living in Ahmedabad, India. Over the last 7+ years, I have developed a wide range of websites using HTML, HTML5, WordPress, Joomla, Magento and Core PHP including sites for startup companies and small businesses. My core competency lies in complete end-end management of a new website development project, and I am seeking opportunities to build websites from the ground up for you or your business. also You can find me on Facebook, Twitter and Google+

Leave a Reply