0

我正在研究magento的注销按钮。现在,当我单击注销按钮时,它将退出页面并重定向到当前页面。

在注销页面模板中

<div class="page-head">
    <h3><?php echo $this->__("You're now Logged Out") ?></h3>
</div>
<p><?php echo $this->__('You have been successfully logged out and will be redirected to our homepage in 5 seconds.') ?></p>
<script type="text/javascript">
setTimeout(function(){ location.href = '<?php echo $this->getUrl() ?>'},5000);
</script>

在我发现的 customer.xml 中

<reference name="root">
    <action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
    <block type="core/template" name="customer_logout" template="customer/logout.phtml"/>
</reference>

现在我想将页面重定向到直接当前页面,而不是去注销页面。希望你能理解并帮助我。

4

2 回答 2

0

您是否查看过处理注销的现有 Magento 代码?

班级Mage_Customer_AccountController

/**
 * Customer logout action
 */
public function logoutAction()
{
    $this->_getSession()->logout()
        ->setBeforeAuthUrl(Mage::getUrl());

    $this->_redirect('*/*/logoutSuccess');
}

看到“setBeforeAuthUrl()”函数了吗?尝试使用它来注入您可以检索的当前 URL:Mage::helper('core/url')->getCurrentUrl();

于 2013-08-08T13:24:25.143 回答
0

你可以尝试改变

<script type="text/javascript">
setTimeout(function(){ location.href = '<?php echo $this->getUrl() ?>'},5000);
</script>

<script type="text/javascript">
setTimeout(function(){ location.href = document.referrer},5000);
</script>
于 2013-08-08T13:27:40.887 回答