`
cgzhang
  • 浏览: 71988 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

How to redirect to another url in block or template

阅读更多
In Block class:

public function _toHtml(){
		Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri());  
		if (!Mage::getSingleton('customer/session')->isLoggedIn()){
	 		header("Status: 301");
   			header('Location: '.$this->getUrl('customer/account/login')) ;  // send to the login page
    		exit; 
	 	}
	}


In template(phtml):
Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri());  
		if (!Mage::getSingleton('customer/session')->isLoggedIn()){
	 		header("Status: 301");
   			header('Location: '.$this->getUrl('customer/account/login')) ;  // send to the login page
    		exit; 

0
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics