I want to create a view with filters and pagination for Joomla 3.x, but I'm not sure about what I have to include and where.
For now, my model extends JModelList
and I started using the getListQuery()
method to fetch the data:
<?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;
}
}
My view.html.php looks like this:
<?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);
}
}
What do I have to add to my model and my view? What is it that I have to include in my default.php so that both filters and pagination work?