我正在研究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>
现在我想将页面重定向到直接当前页面,而不是转到注销页面。希望你理解并帮助我。
答案 0 :(得分:0)
您是否看过处理注销的现有Magento代码?
班级Mage_Customer_AccountController
/**
* Customer logout action
*/
public function logoutAction()
{
$this->_getSession()->logout()
->setBeforeAuthUrl(Mage::getUrl());
$this->_redirect('*/*/logoutSuccess');
}
请参阅“setBeforeAuthUrl()”函数?尝试使用它来注入您可以使用Mage::helper('core/url')->getCurrentUrl();
答案 1 :(得分: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>