Magento获取当前页面URL地址

Magento获取当前页面URL地址

http://www.sunhaibing.com/?p=1260

在Magento中,可以通过core/url助手类中的getCurrentUrl()方法获取当前页面的URL地址

$currentUrl = $this ->helper( 'core/url' )->getCurrentUrl();
//在社会化分享中,当前页面的URL地址非常有用
<a addthis:url= "<?php echo $this->helper('core/url')->getCurrentUrl(); ?>" >Share on Facebook</a><span>
 

--------------------------------------------------

Magento得到当前页面的URL,得到当前产品页面的URL

http://blog.csdn.net/hipihi_0/article/details/7719381

<?PHP

//获取当前URL

echoMage::helper('core/url')—>getCurrentUrl();

//判断是否为首页

if(Mage::getSingleton('cms/page')->getIdentifier() =='home' && Mage::app()->getFrontController()->getRequest()->getRouteName() =='cms') :

//如果是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登陆之后返回登录之前的页面

http://www.zuimoban.com/php/magento/3018.html

在购物车页面添加登录框时我们往往不需要默认的跳转至“我的账户”页面,这个时候我们就需要进行设置Magento登陆之后返回登录之前的页面

在Cart页面添加

Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure'=>true)));

或者 

Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper("core/url")->getCurrentUrl());

即可实现Magento登陆之后返回登录之前的页面

转载于:https://www.cnblogs.com/ec04/p/6281861.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值