douzi2749 2013-11-12 18:26
浏览 135
已采纳

Magento从那里重定向到页面

I have a module which had instaled a CMS page with some default URL and some text with form. On this form I have fields and submit. I validate my fields using ajax(send POST in controller of my module). If validation is OK, I redirect to the same page with "succes message".

The problem is, that the default URL of this CMS page in which I make redirect after succes submit can be changed in BO - that's why I cannot just $this->_redirect('default_URL') in my controller, because this url can be changed.

What should I do?

EDIT : Solution: use $this->_redirectReferer() in my controller after success validation

  • 写回答

3条回答 默认 最新

  • dou7851 2013-11-12 19:14
    关注

    Try to put "back URL" to your form as a hidden field or you can use $this->_redirectReferer() to redirect back to CMS page.

    See http://docs.magentocommerce.com/Mage_Core/Mage_Core_Controller_Varien_Action.html#method_redirectReferer

    If you want to redirect to some certain CMS page (not the one where form is placed) you can do this:

    1. Add dropdown to system configuration to be able to select "Success page" (much better than hardcode cms page ID)

    2. Redirect to this page in your controller

    Code:

    $pageId = Mage::getStoreConfig('mymodule/config/success_page');
    $page = Mage::getModel('cms/page')->load($pageId);
    $this->_redirect($page->getUrlKey());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料