+91 796-525-5075 ( 11AM To 7PM-IST )
Hr@logicrays.com
Biz@logicrays.com
 

Magento : Get base URL, Current URL, Store URL, Skin URL, Media URL & Js URL

Get URLs in CMS pages or static blocks

Base URL

{{base url=”}}

Store URL

{{store url=’logicrays-test.html’}}

also only store URL :  {{store url=””}}

Media URL

only get media URL : {{media url=”}}

if you get some folder path : {{media url=’imagefolder/imagename.jpg’}}

Skin URL

{skin url=’images/imagename.jpg’}}

only get skin URL

{skin url=”}}

 

Get URLs in PHP files (incl. templates/PHTML)

Get Base Url in magento:

$baseurl = Mage::getBaseUrl();

Get Base Url without index.php

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

// output: http://example.com/

Current Url

$currentUrl = Mage::helper(‘core/url’)->getCurrentUrl();  or  $currentUrl = Mage::getUrl(‘*/*/*’, array(‘_current’ => true));

or
if (!in_array(Mage::app()->getFrontController()->getAction()->getFullActionName(), array(‘cms_index_noRoute’, ‘cms_index_defaultNoRoute’)))
{
$currentUrl = Mage::helper(‘core/url’)->getCurrentUrl();
}

Skin URL

$skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

Unsecure Skin URL

$skinUrl = $this->getSkinUrl(‘images/imagename.jpg’);

Secure Skin URL

$this->getSkinUrl(‘images/imagename.gif’, array(‘_secure’=>true));

Media URL

$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); or  $mediaUrl = Mage::getBaseUrl(‘media’);

Get Js URL

$jsUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); or $jsUrl = Mage::getBaseUrl(‘js’);

get store URL

$storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

Get Home URL

$homeUrl= Mage::helper(‘core/url’)->getHomeUrl();

Get Directory paths

Mage::getBaseDir(‘design’) // Get design directory path
Mage::getBaseDir(‘code’) // Gives code directory file path
Mage::getBaseDir(‘lib’) // Gives lib directory file path
Mage::getBaseDir(‘skin’) // Gives skin directory file path
Mage::getBaseDir(‘var’) // Gives var directory file path
Mage::getBaseDir(‘cache’) // Gives cache directory file path
Mage::getBaseDir(‘log’) // Gives log directory file path

Create module URL

Mage::getUrl(‘module/controller/action’);

For More Information Contact Us

Phone (India) Phone (USA) Skype - Voice Call (Eng) Sales / Partnership / Inquiry
+91 796-525-5075 (LL) (213) 426-8337 logicraysinc Biz@logicrays.com
11 AM-8 PM (IST) 9 AM-5 PM 11 AM-8 PM (IST) 11 AM-8 PM (IST)
We provide 100% free Consulting for your IT - Web Development project via Voice call (Skype, Phone)