我在 joomla 2.5 中编写了一个组件。我想要一个视图在视图上使用多个模型。
我的代码:在类控制器(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);
}
但是,视图不能显示到窗体!!!
帮我!!谢谢你们。