Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Pagination in joomla

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 493
    Comment on it

    The JPagination class allows developers to reliably and consistently add pagination to the Front-end and Back-end display of their components. The file containing the class can be found at /libraries/joomla/html/pagination.php.

    The construct function of the class requires three variables: $total - the total number of items in a list, $limitstart - the offset of the item at which to start, and $limit - the number of items to display per page.

    In my case I wanted Pagination for the products. therefore in controller extend the joomla pagination class.

    function product() { $limit = 20; $limitstart = JRequest::getVar('limitstart', 0, '', 'int');

    $db=JFactory::getDBO();
    $query_2 = 'SELECT * FROM #__rg_products';
    $db->setQuery($query_2);
    $detail = $db->loadAssoclist();   
    jimport('joomla.html.pagination');
    $pagination = new JPagination(count($detail), $limitstart, $limit); 
    
    $query = "SELECT * FROM #__rg_products ORDER BY id LIMIT ".$limitstart.", ".$limit." ";
    $db->setQuery( $query );
     $arrresult = $db->loadAssoclist();
    
    $query_3 = "SELECT * FROM #__rg_categories WHERE level = '1' ; " ;
    $db->setQuery($query_3);
    $catresult = $db->loadAssoclist();
    

    // echo"

    "; print_r($catresult); exit;

    $this->assignRef('catresult', $catresult);
    $this->assignRef('arrresult', $arrresult);
    $this->setLayout('product');
    $this->assignRef('pagination', $pagination);
    parent::display();
    
    }
    

    In our view.php we can use any of the 2 functions to display the pagination: 1.) getPagesLinks(): Returns an HTML string to display the Pages Links as << Start Prev 1 2 Next End >> 2.) getListFooter(): Returns a combination of the several page-related elements, including: the Display Limit dropdown, the Pages Links and the Pages Counter. Appearance differs in the Front-end and Back-end due to additional CSS formatting applied with the Khepri template.

    Make sure that these functions are inside the form in your file specifically when using for back-end, pagination->getPagesLinks(); ?>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: