1、Get Base URL
2、Get Current URL
3、Get Home URL
4、Create module your
5、Get secure URL
To get secure URL you just need to add one more parameter as bellow,
6、Get Directory paths
Same way you can get more directory path,
Get Skin URL
Get Media URL
Get Store URL
8、 get url paths in phtml.
Mage::getBaseUrl() => Get base url path e.g. http://yourwebsite.com/
Mage::getBaseUrl('media') => Get MEDIA folder path e.g. http://yourwebsite.com/media/
Mage::getBaseUrl('js') => Get JS folder path e.g. http://yourwebsite.com/js/
Mage::getBaseUrl('skin') => Get SKIN folder path e.g. http://yourwebsite.com/skin/2、Get Current URL
Mage::helper('core/url')->getCurrentUrl();3、Get Home URL
Mage::helper('core/url')->getHomeUrl();4、Create module your
Mage::getUrl('module/controller/action');5、Get secure URL
To get secure URL you just need to add one more parameter as bellow,
Mage::getUrl('',array('_secure'=>true))
Mage::getUrl('module/controller/action',array('_secure'=>true))6、Get Directory paths
Mage::getBaseDir()
//output : /var/www/html/magento
Mage::getBaseDir('app')
//output : /var/www/html/magento/app
Mage::getBaseDir('media')
//output : /var/www/html/magento/mediaSame way you can get more directory path,
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 path7、Get URL path in Static Block
Get Base URL
{{base url=''}}Get Skin URL
{{skin url='images/skinimage.jpg'}}Get Media URL
{{media url='/mediaimage.jpg'}}Get Store URL
{{store url=''}}8、 get url paths in phtml.
//Not secure Skin URL
<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>
//Secure Skin URL
<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>
//Get Current URL
$current_url = Mage::helper('core/url')->getCurrentUrl();
//Get Home URL
$home_url = Mage::helper('core/url')->getHomeUrl();
//Get Magento Media URL
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
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);
本文介绍了在Magento中如何使用Mage类的各种方法来获取不同类型的URL和目录路径,包括获取基本URL、当前URL、主页URL、模块URL、安全URL以及各种目录路径等。
290

被折叠的 条评论
为什么被折叠?



