title: Joomla 2.5 pagination
body: <p>I want to add pagination to my component, i've created a simple model with query. I must be missing something. What else do I need here ?</p>
  
  <pre><code>MODEL
  jimport('joomla.application.component.modellist');
  class PaieskaModelPradinis extends JModelList
  {
      public function getListQuery() 
      {
      $db = JFactory::getDBO();
      $query = "SELECT * FROM #__content";
      $db-&gt;setQuery( $query );
      $db-&gt;query( $query );
      $result = $db-&gt;LoadObjectList();
      return $result;
      }
  }
  
  VIEW
  
  jimport( 'joomla.application.component.view');
  class PaieskaViewPradinis extends JView
  {
      protected $items;
      protected $pagination;
      function display ($tpl = null)
      {
          $this-&gt;items = $this-&gt;get('ListQuery');
          $this-&gt;pagination = $this-&gt;get('Pagination');
  
          parent::display($tpl);
      }
  }
  TPL
  foreach ($this-&gt;items as $item) {
      echo $item-&gt;title;
  }
  </code></pre>
  
  <p>EDITED:</p>
  
  <p>I edited a bit code, so now it works fine, almost. Button display(number of rows to display) is not working. And I wonder if this part can be done in a different way ?</p>
  
  <pre><code>    $limit      = JRequest::getVar('limit' , 25);
      $start      = JRequest::getVar('start' , 0);        
      $query      = "SELECT * FROM #__content LIMIT $start, $limit";
  </code></pre>
  
  <p>-</p>
  
  <pre><code>class PaieskaModelPradinis extends JModelList
  {
      public function getItems() 
      {
          $db         = JFactory::getDBO();
          $limit      = JRequest::getVar('limit' , 25);
          $start      = JRequest::getVar('start' , 0);        
          $query      = "SELECT * FROM #__content LIMIT $start, $limit";
          $db-&gt;setQuery( $query );
          $db-&gt;query( $query );
          $lists = $db-&gt;LoadObjectList();
  
          return $lists;
      }
      function getPagination()
      {
          $main = JFactory::getApplication();
          $db         = JFactory::getDBO();
          $limit      = JRequest::getVar('limit' , 25);
          $limitstart = JRequest::getVar('limitstart', 0);
  
          $query      = "SELECT count(title) FROM #__content";
          $db-&gt;setQuery( $query );
          $total      = $db-&gt;loadResult();
  
                  // include a pagination library
  
          jimport('joomla.html.pagination');
          $pagination = new JPagination($total, $limitstart, $limit);
  
          return $pagination;
      }
  }
  
  VIEW
  
  jimport( 'joomla.application.component.view');
  class PaieskaViewPradinis extends JView
  {
      function display($tpl = null)
      {
          $this-&gt;items  = $this-&gt;get('items');
          $this-&gt;pagination = $this-&gt;get('pagination');
  
          parent::display($tpl);
      }
  }
  </code></pre>