magento獲取當前頁面url地址
在magento中,可以通過core/url助手類中的getcurrenturl()方法獲取當前頁面的url地址
$currenturl
=
$this
->helper(
'core/url'
)->getcurrenturl();
//在社會化分享中,當前頁面的url地址非常有用
helper('core/url')->getcurrenturl(); ?>"
>share on facebook
magento得到當前頁面的url,得到當前產品頁面的url
<?php
//獲取當前url
echomage::helper('core/url')—>getcurrenturl();
//判斷是否為首頁
//如果是1.4.x
if($this->geturl('') ==$this->geturl('*/*/*',array('_current'=>true,'_use_rewrite'=>true))):
echo"homepage";
else:
echo"not in homepage";
endif;
補充說明:
$this->helper('core/url')->getcurrenturl();
在購物車頁面新增登入框時我們往往不需要預設的跳轉至“我的賬戶”頁面,這個時候我們就需要進行設定magento登陸之後返回登入之前的頁面
在cart頁面新增
mage::getsingleton('customer/session')->setbeforeauthurl(mage::geturl('*/*/*', array('_secure'=>true)));
或者 mage::getsingleton('customer/session')->setbeforeauthurl(mage::helper("core/url")->getcurrenturl());
即可實現magento登陸之後返回登入之前的頁面