How to add pagination for component front end (Joomla 2.5)

核能气质少年 提交于 2019-12-11 18:43:21

问题


I am new in joomla, i want to know how to add pagination to component for FRONT END, from searching i found only pagination for back end only.


回答1:


So by default there is no pagination in front-end (at least from my knowledge).

It should work like in the backend.

Adding the pagination from the backend in the front-end is not the smoothest thing on earth but this is how it should work:

Your Model should extend JModelList

In the View (view.html.php) you call the Pagination

$this->pagination = $this->get('Pagination');

At the end in the component template (normally default.php) you will just add:

<?php echo $this->pagination->getListFooter(); ?>

For missing CSS classes add the missing files from the administrator side.

Let me know how it works.




回答2:


Thanks Valentin ! For more detail, in the View (view.html.php)

class ProjectViewMyProjects extends JViewLegacy{
protected $items;
protected $pagination;
public function display($tpl=null)
{
$this->items = $this->get('Items');
$this->pagination   = $this->get('Pagination'); 
.............................................
}

At the end in the component template (normally default.php) :

.................[foreach list of db query]...................[endforeach]
$this->pagination->getListFooter();


来源:https://stackoverflow.com/questions/11425327/how-to-add-pagination-for-component-front-end-joomla-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!