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);
}
しかし、ビューはフォームに表示できません!!!
助けて!!皆さん、ありがとうございました。