0

相关代码:

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

根据我可以从文档和我自己以前的问题中挖掘出来的内容,这应该调用saveCategories(). EasyBlogController我尝试将值设置为easyblog, easyblog.php(文件名)以及当前的EasyBlogController(类名)。

单击“保存”按钮只会刷新页面。它不会重定向,也不会重定向echo我在函数 var_dump中放入的任何测试代码。ing并返回正确的值。创建一个控制器对象,然后使用作品。saveCategories()var_dumpJRequest::getVar('controller')'task'$controller->execute('task');

4

2 回答 2

2

您要获取的值显然取决于您尝试调用的控制器的位置,您在这里有几个选项。通常,组件的基本文件夹(可能是 components/com_easyblog)中有一个控制器,它位于一个名为 controller.php 的文件中,其中的类名是 EasyBlogController。

也可能有一个控制器文件夹(components/com_easyblog/controllers),其中包含特定视图的控制器。通常在这种情况下,您将有一个名为“something.php”的文件,并且该类将是“EasyBlogControllerSomething”。对于此选项,您将使用以下命令调用此控制器的 saveCategories 函数:

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"/>
于 2012-06-07T02:59:30.087 回答
-1

尝试:

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

但请确保您的控制器名为 EasyBlogController.php 并有一个名为 saveCategories() 的函数

于 2012-06-05T14:06:00.053 回答