1

I'm trying to create a custom Jtoolbar button in Joomla 2.5. I'd like the button to act very similar to the built in edit button, except I'd like it to be called generate. The button should load a generate view (similar to the singular edit view). It should have form fields for the user to fill out and then click a submit/save button that will run a php module to populate the database with calculated values.

My google searching has been very unproductive. So far I've been able to create the button with in games/view.html.php:

JToolBarHelper::custom('games.generate','extension', 'extension', 'generate', false);

I believe this should call a controller method in controller/games.php called generate().

in controller/games.php:

public function generate()
    {
        JRequest::setVar('view',  'schedule');
            Jcontroller::display();
    }

After much muddling around, this appears to be loading the view and a template tmpl/default.php. This seems wrong, but it's the furthest I've gotten so I'm going to keep going with it until I get it all figured out.

Original Question:

How do I get that controller to load the view/form/fields/template and then run the php script to populate the database. I probably just need a point in the right direction to figure this out. There doesn't seem to be any complete tutorials/examples on adding a custom button.

Jglstewart
  • 696
  • 1
  • 8
  • 16

1 Answers1

0

A couple of years old, and it's for 3.2, but I added this to my controller for a custom view. I needed a layout called insert. I don't know why you couldn't do the same to just change the view.

public function insert()
{
    $this->setRedirect(JRoute::_('index.php?option=com_mycomponent&view=date&layout=insert', false));
}

Calling it the same way from a custom Jtoolbar button. It works, but maybe there is still a better way.

Mike H
  • 69
  • 1
  • 1
  • 5