Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what worked for me:</p> <ol> <li>Download the pagination module from <a href="https://github.com/kloopko/kohana-pagination">https://github.com/kloopko/kohana-pagination</a> (pagination was removed from Kohana 3.2, so this is an adapted module).</li> <li>Install the module in modules/pagination.</li> <li><p>Add the module in bootstrap.php:</p> <pre><code>Kohana::modules(array( // ... other modules ... 'pagination' =&gt; MODPATH.'pagination' )); </code></pre></li> <li><p>Copy the configuration file from modules/pagination/config/pagination.php to application/config/pagination.php.</p></li> <li><p>Add the following actions to your controller:</p> <pre><code> public function action_index() { // Go to first page by default $this-&gt;request-&gt;redirect('yourcontroller/page/?page=1'); } public function action_page() { $orm = orm::factory('your_orm'); $pagination = Pagination::factory(array( 'total_items' =&gt; $orm-&gt;count_all(), 'items_per_page' =&gt; 20, ) ); // Pass controller and action names explicitly to $pagination object $pagination-&gt;route_params(array('controller' =&gt; $this-&gt;request-&gt;controller(), 'action' =&gt; $this-&gt;request-&gt;action())); // Get data $data = $orm-&gt;offset($pagination-&gt;offset)-&gt;limit($pagination-&gt;items_per_page)-&gt;find_all()-&gt;as_array(); // Pass data and validation object to view echo View::factory('yourview/page', array('data' =&gt; $data, 'pagination' =&gt; $pagination)); } </code></pre></li> <li><p>Create yourview/page as follows:</p> <pre><code>&lt;?php foreach($data as $item) { // ...put code to list items here } // Show links echo $pagination; </code></pre></li> <li><p>Modify application/config/pagination.php according to your needs. I had to change the <code>'view'</code> parameter to <code>'pagination/floating'</code> which displays ellipses (...) when the list of pages is too large, unlike the default <code>'pagination/basic'</code> which lists all pages regardless of length.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload