在 magento 中将登录重定向的 if 语句放在哪里?
Where to place if statement for login redirect in magento?
您好,基本上我需要将我的页面重定向到 login/register。html 我目前正计划使用:
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirect(Mage::getUrl("customer/account/login"));
}
问题是我不知道把语法放在哪里
我想知道我把它放在哪里?我使用一个事件?有没有更好的方法来实现它?我正在使用 magento 顺便说一句
流程是点击导航 -> 检查用户是否登录 -> 如果没有重定向到 login/register 页面
/**
* Check available actions
*
* @return Mage_Core_Controller_Front_Action
*/
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirect('customer/account/login');
}
}
您好,基本上我需要将我的页面重定向到 login/register。html 我目前正计划使用:
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirect(Mage::getUrl("customer/account/login"));
}
问题是我不知道把语法放在哪里 我想知道我把它放在哪里?我使用一个事件?有没有更好的方法来实现它?我正在使用 magento 顺便说一句
流程是点击导航 -> 检查用户是否登录 -> 如果没有重定向到 login/register 页面
/**
* Check available actions
*
* @return Mage_Core_Controller_Front_Action
*/
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirect('customer/account/login');
}
}