SomeKittens
SomeKittens

Reputation: 39512

Controller/JToolBar not working in Joomla 2.5

Relevant code:

JToolBarHelper::custom('saveCategories', 'save', '', 'Save', false, false);
...
<input type="hidden" name="controller" value="EasyBlogController">

According to what I can dig up from the docs and my own previous questions, this should call the saveCategories() function in the EasyBlogController. I've tried setting the value to easyblog, easyblog.php (file name) as well as the current EasyBlogController (Class name).

Clicking on the Save button only refreshes the page. It does not redirect, echo or var_dump any test code I put in the saveCategories() function. var_dumping JRequest::getVar('controller') and 'task' do return the correct values. Creating a controller object and then using $controller->execute('task'); works.

Upvotes: 0

Views: 1394

Answers (2)

David Fritsch
David Fritsch

Reputation: 3731

The values that you are going for depend obviously on the location of the controller that you are trying to call, and you have a couple options here. Typically there is a controller in the base folder of the component (likely components/com_easyblog) that is in a file called controller.php and the class name inside of it would be EasyBlogController.

There may also be a controllers folder (components/com_easyblog/controllers) that would contain controllers for particular views. Typically in this case, you would have a file called "something.php" and the class will be "EasyBlogControllerSomething". For this option, you would call this controller's saveCategories function by using the following:

JToolBarHelper::custom('Something.saveCategories', 'save', '', 'Save', false, false);

Otherwise, if you just want the base controller, just don't specify the controller, since the system will default to the controller.php file. Such as the following:

JToolBarHelper::custom('saveCategories', 'save', '', 'Save', false, false); //no hidden input after this

If you want to set a controller other than the default, add this html to your view:

<input type="hidden" name="controller" value="controllerNameHere"/>

Upvotes: 2

S&#248;ren Beck Jensen
S&#248;ren Beck Jensen

Reputation: 1676

Try:

JToolBarHelper::custom('EasyBlogController.saveCategories', 'save', '', 'Save', false, false);

But make sure that your controller is called EasyBlogController.php and has a function called saveCategories()

Upvotes: -1

Related Questions