【发布时间】:2012-12-31 11:32:45
【问题描述】:
我一直在关注文档here 向现有组件添加(改进的)文件上传部分。
上例中的控制器/模型的链接是通过 post 参数形成的,然后处理上传:
post_params:
{
"option" : "com_mycomponent",
"controller" : "mycontroller",
"task" : "mytask",
"id" : "'.$myItemObject->id.'",
"'.$session->getName().'" : "'.$session->getId().'",
"format" : "raw"
},
我的问题是使用 Joomla 2.5 中引入的新控制器方法无法上传:
// Get an instance of the controller prefixed by the component
$controller = JController::getInstance('mycomponent');
// Perform the Request task
$controller->execute(JRequest::getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
这工作(确实在 Joomla 2.5 上)在旧的 1.5 加载控制器方法上工作得非常好:
// Create the controller
$classname = 'mycomponentController'.$controller;
$controller = new $classname( );
// Perform the Request task
$controller->execute( JRequest::getVar('task'));
// Redirect if set by the controller
$controller->redirect();
虽然后一种方法与 Joomla 2.5 兼容,但不幸的是,我希望与之集成的组件使用了较新的方法,我不想更改它,因此我可以根据需要不断更新组件,而不必每次都更改它。另外,如果我确实更改了它,我猜我可能会失去现有的功能。
基本上我想知道如何设置后参数,以便正确调用新的控制器方法!
编辑
此后我尝试使用以下参数配置:
post_params:
{
"option" : "com_mycomponent",
"task" : "mycontroller.mytask",
"id" : "'.$myItemObject->id.'",
"'.$session->getName().'" : "'.$session->getId().'",
"format" : "raw"
},
我试图模仿index.php?option=com_mycomponent&task=mycontroller.mytask 等的链接。但这仍然不起作用
【问题讨论】:
标签: joomla joomla2.5 swfupload