Magento标签更改/重定向

编程入门 行业动态 更新时间:2024-10-15 04:21:01
本文介绍了Magento标签更改/重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有两个选项卡的页面,一个搜索选项卡和一个带有数据库网格的选项卡.在用户编辑了网格中的一项之后,我想将它们保留在网格选项卡上,而不是放在顺序中的表单选项卡上.

I have a page with two tabs, a search-tab and a tab with a grid of the database. After the user edits one of the items in the grid, I'd like to keep them on the grid tab, rather than the form tab which is first in order.

是否可以通过代码更改页面上的活动标签?

Is there a way to change the active tab on a page via code?

这是标签的代码:

protected function _beforeToHtml() { $this->addTab('search_string', array( 'label' => Mage::helper('advancedtranslate')->__('Find a string'), 'title' => Mage::helper('advancedtranslate')->__('Find a string'), 'content' => $this->getLayout()->createBlock("advancedtranslate/adminhtml_advancedtranslate")->toHtml(), 'active' => true )); $this->addTab('list_untranslated', array( 'label' => Mage::helper('advancedtranslate')->__('Untranslated strings'), 'title' => Mage::helper('advancedtranslate')->__('Untranslated strings'), 'content' => $this->getLayout()->createBlock("advancedtranslate/adminhtml_grid")->toHtml(), 'active' => false )); return parent::_beforeToHtml(); }

这是控制器中用于处理重定向的saveAction:

And this is the saveAction in my controller that handles the redirect:

public function saveAction(){ //write data away to core_translate table $resource = Mage::getResourceModel('core/translate_string'); $request = $this->getRequest(); $translate_id = $request->getParam('id'); $original = $request->getParam('original_translation'); $custom = $request->getParam('string'); $locale = $request->getParam('locale'); $storeId = $request->getParam('storeid'); $storeViewSpecific = $request->getParam('storeview_specific'); if($storeId != 0 && $storeViewSpecific != 1){ $storeId = 0; } $resource->saveTranslate($original, $custom, $locale, $storeId); //delete record from phpro table $advancedTranslateRecord = Mage::getModel('advancedtranslate/advancedtranslate'); $advancedTranslateRecord->setId($translate_id) ->delete(); //clear the cache Mage::app()->getCache()->clean(); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml') ->__('Translation was saved.')); $this->_redirect('*/*/'); }

推荐答案

是的,您可以通过更改_beforeToHtml()中的'active'=> true/false属性来实现 ...只需在saveAction()中传递一个参数或设置一个会话值即可...因此,当页面被重定向时,您可以检查beforeToHtml()是否设置了该参数,您可以更改'active'=> $ somevariable的顺序

Yes you can do so by changing the 'active' => true / false attribute in your _beforeToHtml() ... simply pass a parameter or set a session value in your saveAction()... so when the page gets redirected you check in your beforeToHtml() if the parameter is set you change the order of 'active' => $somevariable.

基本上是这样,

protected function _beforeToHtml() { $active = true; if(Mage::getSingleton('admin/session')->getData('ActiveTab')) { $active = false; } $this->addTab('search_string', array( 'label' => Mage::helper('advancedtranslate')->__('Find a string'), 'title' => Mage::helper('advancedtranslate')->__('Find a string'), 'content' => $this->getLayout()->createBlock("advancedtranslate/adminhtml_advancedtranslate")->toHtml(), 'active' => $active )); $this->addTab('list_untranslated', array( 'label' => Mage::helper('advancedtranslate')->__('Untranslated strings'), 'title' => Mage::helper('advancedtranslate')->__('Untranslated strings'), 'content' => $this->getLayout()->createBlock("advancedtranslate/adminhtml_grid")->toHtml(), 'active' => !$active )); return parent::_beforeToHtml(); }

更多推荐

Magento标签更改/重定向

本文发布于:2023-11-02 00:18:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550824.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   标签   Magento

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!