Magento:从模板重定向到主页?

时间:2014-05-14 08:07:19

标签: magento redirect

我在catalog \ product \ compare \ list.phtml中,我想重定向到主页,如下所示:

if($someThing) {
    // redirect to homepage
    $this->_redirect('home'); // --> doesnt work
    $this->_redirect(Mage::getBaseUrl()); // --> doesnt work
}

我尝试了几件事,到目前为止都没有。我该怎么做?

谢谢!

2 个答案:

答案 0 :(得分:2)

据我所知,$ this-> _redirect只能在控制器中使用。

请改为尝试:

    Mage::app()->getFrontController()->getResponse()->setRedirect($this->getBaseUrl());

答案 1 :(得分:2)

尝试以下

header("Location:".Mage::getBaseUrl());
exit();

或者

 Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
exit();
相关问题