【问题标题】:Multiple model on a view Joomla 2.5视图上的多个模型 Joomla 2.5
【发布时间】:2013-04-07 06:35:20
【问题描述】:

我在 joomla 2.5 中编写了一个组件。我想要一个视图在视图上使用多个模型。

我看到Multiple models for a view without controllers

我的代码: 在类控制器(Controller.php)中

public function display($cachable = false, $urlparams = false) 
{
        AppHelper::addSubmenu(JRequest::getCmd('view', 'apps'));
        JRequest::setVar('view', JRequest::getCmd('view', 'apps'));

        $model = $this->getModel('app'); // get first model
        $view = $this->getView('apps', 'html'); // get view we want to use
        $view->setModel($model, true);  //  true is for the default model  

        $vermodel = &$this->getModel('version'); // get second model   
        $this->assignRef('version', $vermodel);

        $view->setModel($vermodel);
        var_dump($this);

        parent::display($cachable);
        return $this;
}

在类视图中(view.html.php)

public function display($tpl = null) 
{
        // Initialiase variables.
        $this->form = $this->get('Form');

        $this->item = $this->get('Item');
        $this->state = $this->get('State');
        $this->form2 = $this->get('Form', 'version');
       // var_dump($this->form2);

    }

但是,视图不能显示到窗体!!!

帮帮我!!谢谢大家。

【问题讨论】:

  • 您是否检查过 - 您的“版本”模型是否在视图中可用?

标签: components joomla2.5


【解决方案1】:

代替: $this->form2 = $this->get('Form', 'version'); 你应该使用: $this->form2 = $this->getForm();

对我来说它有效。我想只有一个默认模型,这就是为什么我们应该以其他方式调用模型的函数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-21
    • 2012-03-31
    • 2013-09-30
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多