Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

magento Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url ,home url , module url , drirectory url userfull reference for magento

Hello here some useful code for Magento developer

Get Url in cms pages or static blocks


1)Base Url :

{{base url=''}}

2)Store Url :

{{store url='test.html'}} also only store url

{{store url=""}}

3)Media Url :

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

4)Skin Url :

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

only get skin url {skin url=''}}

Get Url in phtml files in magento 


1) Get Base Url  in magento:

$baseurl = Mage::getBaseUrl();


2) 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();
}

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

4)media Url

$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

or
$mediaUrl = Mage::getBaseUrl('media');

5)Get Js Url : 

$jsUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

or 

$jsUrl = Mage::getBaseUrl('js');

6)Get Store Url : 

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

7)Get Home URL

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

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

9)create module
Mage::getUrl('module/controller/action');







0 komentar:

Post a Comment

magento Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url ,home url , module url , drirectory url userfull reference for magento