articleと呼ばれるコントローラーには、データベースからのデータを表示するために使用している次の関数があります。
function get_all(){
$this->load->library('pagination');
$config['base_url'] = base_url().'article/get-all';
$config['total_rows'] = 2; // example
$config['per_page'] = 1;
$config['num_links'] = 20;
$config['full_tag_open'] = '<div class="pagination" align="center">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$this->load->model('mod_articles');
$data['records']= $this->mod_articles->get_articles_this_year($config['per_page'],$this->uri->segment(3));
$this->load->view('view_article_list',$data);
}
通常、関数に到達するためhttp://localhost/article/get_all
の URL は: ですが、URL を次のようにするためhttp://localhost/article/get-all
に、config/route.php に次の行を追加しました。
$route['article/get-all'] = "article/get_all";
正常に動作していますが、ページネーション リンクをクリックして次のページに移動すると、404 Page Not Foundと表示されます。
URI ルーティング ワイルドカードの適切な使用方法を教えてください。
編集
URLにインデックスが表示されないように、config/route.phpに次のものもあります
$route['article/(:any)'] = "article/index/$1";
上記の行を削除すると、ページネーションが機能します。