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);

One response to “How to getBaseUrl in Magento

  1. http://www.memstar.com.au/ 07/07/2014 at 5:38 PM

    Way cool! Some extremely valid points! I appreciate you writing this
    write-up and the rest of the website is also very good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: