Yesterday I started to write my own component. But there is a problem with understanding how pagination should work. Before Ш start a topic, I've read all the available topics in the JDM group about it.
Model
class OwlModelOwls extends JModelList {
protected function populateState($ordering = 'ordering', $direction = 'ASC') {
$app = JFactory::getApplication();
$limit = $app->input->get('limit', 25, 'uint');
$this->setState('limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('limitstart', $limitstart);
$this->setState('ordering', $ordering);
}
protected function getListQuery() {
$db = $this->getDBO();
$query = $db->getQuery(true);
$query->select("`m`.`id`, `m`.`parent_id`, `m`.`title`, `m`.`alias`, `m`.`introtext`, `m`.`desc`, DATE_FORMAT(`m`.`year`, '%Y') AS `year`, DATE_FORMAT(`m`.`created`, '%Y-%m-%d') AS `created`, DATE_FORMAT(`m`.`modified`, '%Y-%m-%d') AS `modified`, `g`.`filename`");
$query->from($db->quoteName('#__m').' AS `m`');
$query->leftJoin($db->quoteName('#__gallery').' AS `g` ON `g`.`is_m` = 1 AND `g`.`m_id` = `m`.`id` AND `g`.`is_poster` = 1 AND `g`.`is_poster_frontpage` = 1');
$query->where('`language` IN ('.$db->quote(JFactory::getLanguage()->getTag()).','.$db->quote('*').')');
$query->order('`ordering` DESC');
return $query;
}
}View
class OwlViewOwls extends JViewLegacy {
protected $state = null;
protected $items = null;
protected $pagination = null;
public function display($tpl = null) {
$user = JFactory::getUser();
$app = JFactory::getApplication();
$state = $this->get('State');
$items = $this->get('Items');
$pagination = $this->get('Pagination');
$params = $app->getParams('com_owl');
$this->params = &$params;
$this->items = &$items;
$this->pagination = &$pagination;
$this->user = &$user;
$this->_prepareDocument($params);
parent::display($tpl);
}
}Template
** foreach for list of items
<div class="pagination">
<p class="counter pull-right"><?php echo $this->pagination->getPagesCounter(); ?></p>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
And this is doesn't work. Paginator is not shown. Just blank <div> and <p>. If I do
print_r() for
$this->pagination I see
JPagination Object
(
[limitstart] => 0
[limit] => 2
[total] => 2
[prefix] =>
[pagesStart] => 1
[pagesStop] => 1
[pagesCurrent] => 1
[pagesTotal] => 1
[viewall:protected] => 1
[additionalUrlParams:protected] => Array
(
)
)
What's wrong and where's the mistake?
PS! In debugging I see 2 identical sql query.