Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

How to getBaseUrl in Magento


When developing in Magento and playing arround with Magento Themes there is some functions you should know.
If you want to get the source url of an image, javascript or file, call one of this functions adding your own path at the end.
Under every function there is an example of the output value:

//http://example.com/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
//http://example.com/js/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
//http://example.com/index.php/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
//http://example.com/media/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
//http://example.com/skin/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Advertisements

Comments are closed.

%d bloggers like this: