php - CI index method/function not automatically added for some cases? -
if give method/function's name index in codeigniter, can go method without calling (so need use controller name).
that because specify (or ci specifies default) in config.php :
$config['index_page'] = 'index.php'; so when use library form_validation, don't need specify index method. however, have problem when tried use pagination class.
i need specify index method in code, or pagination doesn't work (it gives 404 error if click next pagination index) :
$config['base_url'] = site_url('/backend_umat'); so, have use :
$config['base_url'] = site_url('/backend_umat/index'); and pagination works perfectly.
please, can kindly give me explanation what's going on? problem solved, i'm curious what's going on here.
thanks :d
in codeigniter pagination:
$config['base_url']should complete url. i.e.,base_url()/{controller}/{function}.- so if not giving complete path, pagination class ignore {function} , create links like:
base_url()/{controller}/{page1} , base_url()/{controller}/{page2} , base_url()/{controller}/{page3}, on... instead ofbase_url()/{controller}/{function}/{page_no}
in place of function there's number (page number) not present in controller class assumed function inside controller. that's reason getting 404 page not found error.
there 2 ways solve this.
- the way have done it.
$config['base_url'] = site_url('/backend_umat/index'); - use routes.
inside routing.php file define this:
$route['backend_umat/(:num)'] = 'backend_umat/index/(:num)';
in controller:$config['uri_segment'] = 2;
, if have used:$this->uri->segment(3)in code, make$this->uri->segment(2)
do.
Comments
Post a Comment