// Create the view,创建一个view的对象;
$view =& $this->getView('article', 'html');
// Get/Create the model, 继承或者是创建一个model的对象
$model =& $this->getModel('Article' );
// Push the model into the view (as default),把模型的对象推入view中;
$view->setModel($model, true);
// Display the view,显示view
$view->display();
实例:Controller中的getView()和getModel()的使用方法:
getView()——获取view的对象,其参数的使用方法如下:
$view =& $this->getView('stock','feed');
stock的参数是view的文件夹名称,如stock表示\components\com_stock\views\stock
feed表示该模板文件名称的中间部分:view.feed.php
getModel()——获取model的对象,其参数的使用方法如下:
$model =& $this->getModel('feed');
该行代码将会调用\components\com_stock\models\feed.php,并实例化里面的对象StockViewFeed().