Show
Ignore:
Timestamp:
04/26/2008 01:44:42 AM (7 months ago)
Author:
Geert
Message:

Updating pagination example the proper way

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r2580 r2581  
    256256        { 
    257257                $pagination = new Pagination(array( 
    258                         // 'base_url'    => 'welcome/pagination_example/page/', // base_url will default to current uri 
    259                         'uri_segment'    => 'page', // pass a string as uri_segment to trigger former 'label' functionality 
    260                         // 'query_string'   => 'pee', 
    261                         'total_items'    => 254, // use db count query here of course 
    262                         'items_per_page' => 10, // it may be handy to set defaults for stuff like this in config/pagination.php 
    263                         'style'          => 'classic' // pick one from: classic (default), digg, extended, punbb, or add your own! 
     258                        // Base_url will default to the current URI 
     259                        // 'base_url'    => 'welcome/pagination_example/page/x', 
     260 
     261                        // The URI segment (integer) in which the pagination number can be found 
     262                        // The URI segment (string) that precedes the pagination number (aka "label") 
     263                        'uri_segment'    => 'page', 
     264 
     265                        // You could also use the query string for pagination instead of the URI segments 
     266                        // Just set this to the $_GET key that contains the page number 
     267                        // 'query_string'   => 'page', 
     268 
     269                        // The total items to paginate through (probably need to use a database COUNT query here) 
     270                        'total_items'    => 254, 
     271 
     272                        // The amount of items you want to display per page 
     273                        'items_per_page' => 10, 
     274 
     275                        // The pagination style: classic (default), digg, extended or punbb 
     276                        // Easily add your own styles to views/pagination and point to the view name here 
     277                        'style'          => 'classic', 
     278 
     279                        // If there is only one page, completely hide all pagination elements 
     280                        // Pagination->render() will return an empty string 
     281                        'auto_hide'      => TRUE, 
    264282                )); 
    265283 
    266                 // Just echoing it is enough to display the links (__toString() rocks!) 
     284                // Just echo to display the links (__toString() rocks!) 
    267285                echo 'Classic style: '.$pagination; 
    268286 
    269287                // You can also use the render() method and pick a style on the fly if you want 
    270                 echo '<hr />Digg style:     '.$pagination->render(); 
    271                 echo '<hr />Extended style: '.$pagination->render('extended'); 
    272                 echo '<hr />PunBB style:    '.$pagination->render('punbb'); 
     288                echo '<hr /> Digg style:     ', $pagination->render('digg'); 
     289                echo '<hr /> Extended style: ', $pagination->render('extended'); 
     290                echo '<hr /> PunBB style:    ', $pagination->render('punbb'); 
    273291                echo 'done in {execution_time} seconds'; 
    274292        }