简体   繁体   English

自定义组件中的Joomla 3.x Override按钮功能

[英]Joomla 3.x Override button functions in custom component

I'm trying to override the buttons in my joomla component. 我正在尝试覆盖joomla组件中的按钮。

I've managed fine with the save function by adding code into the controller. 通过将代码添加到控制器中,我已经使用save函数进行了很好的管理。

            public function save($key = null, $urlVar = null)
                {
                    $uri = JUri::getInstance(); 


                    $requestData = JRequest::getVar('jform', array(), 'post', 'array');
                    $user =& JFactory::getUser();
                    $userId = $user->get( 'id' );

                    $idToUse = $requestData['id'];

I want to do the same thing with save and close and save and new but I can't figure out how to do it. 我想对save和close以及save和new做同样的事情,但是我不知道该怎么做。 I thought that I needed to go to the view.html and look at the custom functions: 我认为我需要转到view.html并查看自定义函数:

            JToolBarHelper::title(JText::_('COM_SHOPPER_TITLE_SELECTOR'), 'selector.png');

            // If not checked out, can save the item.
            if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create'))))
            {
                JToolBarHelper::apply('selector.apply', 'JTOOLBAR_APPLY');
                JToolBarHelper::save('selector.save', 'JTOOLBAR_SAVE');
            }

            if (!$checkedOut && ($canDo->get('core.create')))
            {
                JToolBarHelper::custom('selector.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
            }

So I thought I just needed to add a function save2new() but I can't figure out how to make it work. 所以我以为我只需要添加一个功能save2new(),但我不知道如何使它工作。

Any thoughts on where I'm going wrong would be great. 任何关于我要去哪里的想法都很棒。

I guess you are looking for registerTask . 我猜你在找registerTask

If you want to call save method for save2new task than you need to call registerTask inside constructor __constructor 如果要为save2new任务调用save方法, save2new需要在构造函数__constructor调用registerTask

$this->registerTask('save2new', 'save');

https://docs.joomla.org/API17:JController::registerTask https://docs.joomla.org/API17:JController::registerTask

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM