Magento News

 

Retrieving URL paths (skin,media,js,current,base,home…) in Magento

Magento comes with built in function for retrieving URL paths. Function is called getBaseUrl() and its located under Mage class. However, function is not documented as it should be. Documentation only states that function retrieves $type parametar which is by default equal to “base”.

Here is the list of all the available parameters others found. As you can see, they all come from Mage_Core_Model_Store.

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

http://your-magento-url/js/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

http://your-magento-url/index.php/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

http://your-magento-url/media/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

http://your-magento-url/skin/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

http://your-magento-url/

And some method come from magento core helper: Mage_Core_Helper_Url

Mage::helper('core/url')->getCurrentUrl();//Retrieve current url
Mage::helper('core/url')->getCurrentBase64Url();//Retrieve current url in base64 encoding
Mage::helper('core/url')->getHomeUrl();//Retrieve homepage url

Retrieving URL paths (skin,media,js,current,base,home…) in Magento

Possibly Related Posts:


 

Leave a Reply