我想为Joomla 3.x创建带有过滤器和分页的视图,但是我不确定必须包含哪些内容以及在何处。
现在,我的模型扩展了JModelList
,我开始使用该getListQuery()
方法来获取数据:
<?php
defined('_JEXEC') or die;
class smartModelProducts extends JModelList{
protected function getListQuery(){
// Initialize variables.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Create the base select statement.
$query->select('*')
->from($db->quoteName('#__smart_products'));
return $query;
}
}
我的view.html.php看起来像这样:
<?php
defined('_JEXEC') or die;
class smartViewProducts extends JViewLegacy{
function display($tpl=null){
$app=JFactory::getApplication();
$jinput = $app->input;
$option = $jinput->get('option', null, null);
$user=JFactory::getUser();
// Get data from the model
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
parent::display($tpl);
}
}
我必须在模型和视图中添加什么?为了使过滤器和分页都能正常工作,我必须在default.php中包括什么?