Get base Url, Skin Url, Media Url in both phtml files and cms pages or static blocks – Magento 1x

I have been searching in the web for these helpful code for Magento 1x and gather together here for my own purpose. But you want use these codes into your project then please go head.

Get the URL in CMS pages and Static Blocks

1. Base URL

 {{store url=""}} 

2. Skin URL

 {{skin url='imagefolder/image.png'}} 

3. Media URL

 {{media url="/image.png"}} 

4. Store URL

 {{store url="pagename.html"}} 

Get the URL in phtml file

1. Base URL

 Mage::getBaseUrl(); 

2. Skin URL

 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); 

2.1 Secure URL

 $this->getSkinUrl('imagefolder/image.png', array('_secure'=>true)); 

2.2 Unsecure URL

 $this->getSkinUrl('imagefolder/image.png'); 

3. Current URL

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

4. Js URL

 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); 

5. Store URL

 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); 

6. Media URL

 Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); 



Leave a Reply

Your email address will not be published. Required fields are marked *