【问题标题】:Linking to the new Joomla 2.5 Controller链接到新的 Joomla 2.5 控制器
【发布时间】:2013-01-19 18:07:55
【问题描述】:

很多人都知道 Joomla 2.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();

类似于

// 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 1.5 中以及通过使用表格,您可以通过运行链接来运行任务

index.php?option=com_mycomponent&controller=specificcontroller&task=randomtask

但是这种链接样式不适用于新控制器 - 如果您使用新控制器,有人知道如何在 Joomla 2.5 中格式化此链接吗?

【问题讨论】:

    标签: joomla joomla2.5


    【解决方案1】:

    您可以结合任务和控制器,以便它会调用指定控制器的任务。这些将是.(dot) 分隔的。试试这个-

    index.php?index.php?option=com_mycomponent&view=viewname&task=specificcontroller.randomtask
    

    阅读更多 - http://docs.joomla.org/JController_and_its_subclass_usage_overview

    【讨论】:

    • 谢谢! view=viewname 是必需的吗?
    • 谢谢你 :) 非常感谢
    猜你喜欢
    • 2013-09-02
    • 2013-04-15
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多