How to get Urls in Magento

How to get Urls in Magento

Magento core url helper allows you to get current url. To get current url in magento you just need one line of code as below: ref: public function getCurrentUrl()

$magentoCurrentUrl = Mage::helper('core/url')->getCurrentUrl();

You can also get current url as base64 encoded url as:
$magentoCurrentUrlBase64 = Mage::helper('core/url')->getCurrentBase64Url(); or,
$magentoCurrentUrlBase64 = Mage::helper('core/url')->getEncodedUrl($url); // $url is optional

Same helper allows you to get home url which is base url:
$magentoHomeUrl = Mage::helper('core/url')->getHomeUrl();

Source: app\code\core\Mage\Core\Helper\Url.php To Retrieve URL path in STATIC BLOCK To get SKIN URL
{{skin url='images/sampleimage.jpg'}}

To get Media URL
https://www.eglobeits.com/media//sampleimage.jpg

To get Store URL
https://www.eglobeits.com/mypage.html/

To get Base URL
{{base url='yourstore/mypage.html'}}

TO Retrieve URL path in PHTML Note: In editing PHTML don't forget to enclode the following code with PHP tag Not secure Skin URL:
getSkinUrl('images/sampleimage.jpg') ?>

Secure Skin URL
getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>

Get Magento Media Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

Get Magento Skin Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Get Magento Store Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Magento Js Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

leave a comment