phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Joomla - MVC: Adding Pagination for Back End

Tag: joomla, MVC, pattern, component, pagination   Category: PHP Framework
post: 07 Feb 2008 read: 1,684


Joomla Back End MVC Step by Step Tutorial - Part 4: We have made list table for back end at here. Now, we will add a feature for that table, paginating.

Open again your "controller.php" within Joomla\administrator\components\com_hello. Edit like following code:

joomla mvc backend list paginating

<?
defined('_JEXEC') or die('Restricted Access');
jimport('joomla.application.component.controller');

class HelloController extends JController
{
  function __construct ($default = array())
  {
  	parent::__construct( $default );
  }
  function showHellos()
  {
  	global $options, $mainframe;
	
	$limit      = JRequest::getVar('limit',
	              $mainframe->getCfg('list_limit'));
	$limitstart = JRequest::getVar('limitstart', 0);
	
	$db         =& JFactory::getDBO();
	
	$query		= "SELECT count(*) FROM #__hello";
	$db->setQuery( $query );
	$total		= $db->loadResult();
	
	$query      = "SELECT * FROM #__hello";	
	$db->setQuery ( $query, $limitstart, $limit);
	$rows       = $db->loadObjectList();
	
	if ($db->getErrorNum())
	{
	  echo $db->stderr();
	  return false;
	}
	
	jimport( 'joomla.html.pagination' );
	$pageNav = new JPagination($total, $limitstart, $limit);
  	HTML_hellos::showHellos( $option, $rows, $pageNav );
  }
}
?>

Next, we will modify our admin.html.



Series this article:
Joomla - MVC: Reorganizing Back End Code
Joomla - MVC: Creating Controller and Model for Back End
Joomla - MVC: Creating View for Back End
Joomla - MVC: Adding Pagination for Back End
Joomla - MVC: Adding Element Paginating for Back End
Joomla - MVC: Creating Form Input Data for Back-End
Joomla - MVC: Saving Data for Back End
Joomla - MVC: Editing Data for Back-End
Joomla - MVC: Adding Delete Function at Back-End
Joomla - MVC: Controlling Publish State for Back-End

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting