在magento中获取基本网址:
$baseurl = Mage::getBaseUrl();
不使用index.php即可获取基本网址
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
// output: http://example.com/
当前网址
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
要么
$currentUrl = Mage::getUrl('*/*/*', array('_current' => true));
要么
if (!in_array(Mage::app()->getFrontController()->getAction()->getFullActionName(), array('cms_index_noRoute', 'cms_index_defaultNoRoute')))
{
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
}
皮肤网址:
$skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
不安全的皮肤网址:
$skinUrl = $this->getSkinUrl('images/imagename.jpg');
安全皮肤网址:
$this->getSkinUrl('images/imagename.gif', array('_secure'=>true));
媒体网址
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
要么
$mediaUrl = Mage::getBaseUrl('media');
获取Js URL:
$jsUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
要么
$jsUrl = Mage::getBaseUrl('js');
获取商店网址:
$storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
获取首页网址:
$homeUrl= Mage::helper('core/url')->getHomeUrl();
获取目录路径
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
创建模块URL:
Mage::getUrl('module/controller/action');