【问题标题】:How to Call Joomla Component into module?如何将 Joomla 组件调用到模块中?
【发布时间】:2011-08-11 21:37:09
【问题描述】:

我正在使用 Joomla 站点,我想将一个组件的一些控制器+模型+视图调用到模块中。这怎么可能。

我正在寻找代码来使用我们创建 Jcontroller 的对象,然后将视图的输出输入到模块中,View 也为同一组件使用了一些模型

谢谢 曼吉特

【问题讨论】:

    标签: php module joomla components


    【解决方案1】:
    //set up any request variables that your component controller may need    
    JRequest::setVar('var1','x');
    JRequest::setVar('var2','y');
    
    //include your controller and any other files
    require_once(JPATH_BASE.'components'.DS.'your_component'.DS.'controllers'.DS.'yourcontroller.php');
    
    //Do you need to tell your component you need module output?
    $config = array();
    $config['source'] = 'module';
    $controller = new yourController($config);
    
    $controller->execute('display');
    
    //Reset any Request vars you have set
    JRequest::setVar('var1','');
    JRequest::setVar('var2','');
    

    【讨论】:

      猜你喜欢
      • 2016-01-15
      • 2013-01-15
      • 1970-01-01
      • 2013-09-02
      • 2011-05-01
      • 2011-09-29
      • 2015-07-16
      • 2014-10-27
      • 2012-03-21
      相关资源
      最近更新 更多