Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you use standard pagination :/ nevermind, pagination generated like this:</p> <p>class / function / pagination num</p> <p>URL BASE:</p> <pre><code>$config['base_url'] = 'http://moefoster.com/music/'; </code></pre> <p>ROUTES:</p> <pre><code>$route['music'] = 'music'; $route['music/(:num)'] = 'music/$1'; $route['default_controller'] = "music"; $route['(:any)'] = 'pages/view/$1'; </code></pre> <p>but I use in backend, \libraries\My_Pagination.php</p> <pre><code>&lt;?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Pagination extends CI_Pagination { var $offset = 0; var $pagination_selector = 'page'; var $index_page; function MY_Pagination () { parent::__construct(); log_message('debug', "MY_Pagination Class Initialized"); $this-&gt;index_page = config_item('index_page') != '' ? config_item('index_page') . '/' : ''; $this-&gt;_set_pagination_offset(); } function _set_pagination_offset () { $CI = &amp; get_instance(); if (strstr($CI-&gt;uri-&gt;uri_string(), $this-&gt;pagination_selector)) { $segments = $CI-&gt;uri-&gt;segment_array(); foreach ($segments as $key =&gt; $value) { if ($value == $this-&gt;pagination_selector) { $this-&gt;offset = $CI-&gt;uri-&gt;segment($key + 1); $this-&gt;uri_segment = $key + 1; $uri = $CI-&gt;uri-&gt;uri_string(); $pos = strpos($uri, $this-&gt;pagination_selector); $this-&gt;base_url = '/'.$this-&gt;index_page . substr($uri, 0, $pos + strlen($this-&gt;pagination_selector.'/')); } } } else { $this-&gt;offset = 0; $this-&gt;uri_segment = 0; $this-&gt;base_url = '/'.$this-&gt;index_page . $CI-&gt;uri-&gt;uri_string() . '/' . $this-&gt;pagination_selector.'/'; } } } </code></pre> <p><strong>Example controller</strong></p> <pre><code> function somefunction($somevariable){ $config['total_rows'] = Model_Admin::getCountClankyCategory($somevariable); $config['per_page'] = 25; $config['cur_tag_open'] = '#START SOME HTML#'; $config['cur_tag_close'] = '#END SOME HTML#'; $config['full_tag_open'] = '#START SOME HTML PAGINATION#'; $config['full_tag_close'] = '#END SOME HTML PAGINATION#'; $this-&gt;pagination-&gt;initialize($config); $data['content'] = Model_Admin::getAllClankyCategory($somevariable,$config['per_page'],$this-&gt;pagination-&gt;offset); ..... } </code></pre> <p><strong>some example model</strong></p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Model_Admin extends CI_Model { private static $db; function __construct() { parent::__construct(); self::$db = &amp;get_instance()-&gt;db; } static function getAllClankyCategory($cat,$num,$offset) { self::$db-&gt;where('#MYTYPE#',$cat); return self::$db-&gt;get('#SOMETABLE#',$num,$offset)-&gt;result_array(); } static function getCountClankyCategory($cat) { return self::$db-&gt;count_all_results('#SOMETABLE#'); } </code></pre> <p>then if u use "some hard code routing", routes like, other u use without these routes</p> <pre><code>$route['admin/articles/cat/(:any)'] = "admin/cat/$1"; $route['admin/articles/cat/(:any)/(:num)'] = "admin/cat/$1/$2"; </code></pre>
 

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