CodeIgniter Forums
Pagination Error (using htaccess) [SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Pagination Error (using htaccess) [SOLVED] (/showthread.php?tid=33178)

Pages: 1 2


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-18-2010

[eluser]Deathcode[/eluser]
Hello Guys...

i used CI and trying to make pagination at my back-end but i have a problem when i removed index.php using htaccess, when i click "next" then the error page 404 is showed. How to make pagination work again???

Here is my .htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico|license.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

controller :
Code:
$this->load->library('pagination');
        
$config['base_url'] = base_url().'admin/joblisting';
$config['total_rows'] = $this->db->count_all('jobvacancy');
$config['per_page'] = 5;
$config['num_links'] = 10;
$offset    = (int)$this->uri->segment(3);
$offset = ( ! is_numeric($offset) || $offset < 1) ? 0 : $offset;
        
$this->pagination->initialize($config);
$this->load->model('data_model');
$data['jobRec'] = $this->data_model->getAllJoblist($config['per_page'], $offset);

$data['main_content'] = 'admin_views/joblisting';
$this->load->view('admin_views/site_template/template',$data);
Please help me resolved this coz i already spend 6 hours for this problem and i'm still stuck....

thanks before.


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-18-2010

[eluser]Prensil Technologies Pvt Ltd.[/eluser]
Try to set $config['uri_segment'] parameter. It may help CI to understand the URL.


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-18-2010

[eluser]Deathcode[/eluser]
i already try to set uri segment but it's not work too.....

please tell me if there is another way to fix this problem???

thank you...


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-20-2010

[eluser]pickupman[/eluser]
Try removing the QSA from your .htaccess line. Try this for your controller
Code:
$offset = (int)$this->uri->segment(3,0);
$config['base_url'] = site_url('admin/joblisting');
$config['total_rows'] = $this->db->count_all('jobvacancy');
$config['per_page'] = 5;
$config['num_links'] = 10;        
$this->pagination->initialize($config);

$this->load->model('data_model');
$data['jobRec'] = $this->data_model->getAllJoblist($config['per_page'], $offset);
$data['pagination_links'] = $this->pagination->create_links();



Pagination Error (using htaccess) [SOLVED] - El Forum - 08-25-2010

[eluser]Deathcode[/eluser]
hi pickupman, thanks for your reply...

i already remove QSA in my .htaccess and i change my controller like this :

Code:
function index(){    
$this->load->library('pagination');
        
$offset    = (int)$this->uri->segment(3,0);
$config['base_url'] = site_url('admin/joblisting');
$config['total_rows'] = $this->db->count_all('jobvacancy');
$config['per_page'] = 10;
$config['num_links'] = 10;
$this->pagination->initialize($config);

$this->load->model('data_model');
$data['jobRec'] = $this->data_model->getAllJoblist($config['per_page'],$offset);
$data['pagination_links'] = $this->pagination->create_links();
          
$data['main_content'] = 'admin_views/joblisting';
$this->load->view('admin_views/site_template/template',$data);
}

but it's not working too, when i click "next" the page 404 showed. For yout information i use AUTO in my config['uri_protocol'].


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-25-2010

[eluser]pickupman[/eluser]
Are you using routing? because you have configured the base url of your pagination to be admin/joblisting. This would create links like admin/joblisting/index/(offset). It looks you either need to fix your uri in base url, or change your uri segment for offset to 4, or if using routing you need to use rsegment(3,0).


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-25-2010

[eluser]cchi[/eluser]
check what value does your $this->uri->segment(); gets' i thinks it get the wrong value;

or go to Pagination.php under system/libraries and add parameter to its method;

Code:
function create_links($param='') { ...

$output .= $this->first_tag_open.'<a >base_url.'/'.$param.'">'.$this->first_link.'</a>'.$this->first_tag_close;


.. }



Pagination Error (using htaccess) [SOLVED] - El Forum - 08-25-2010

[eluser]pickupman[/eluser]
Quote:check what value does your $this->uri->segment(); gets’ i thinks it get the wrong value;
There really isn't any reason to touch anything in the system folder. Any changes will be lost when upgrading. CI offers a simple way to extend classes to override the system folder.


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-25-2010

[eluser]Deathcode[/eluser]
yes, i used routing to route my login page. here is my route :
Code:
$route['default_controller'] = "home";
$route['scaffolding_trigger'] = "";
$route['admin'] = "admin/login";

i try to change my segment(3,0) to rsegment(3,0) but the page 404 is showed but if i change my base url like this :

Code:
$config['base_url'] = site_url('admin/joblisting/index');
$offset    = (int)$this->uri->segment(4);

the page 404 is not showed anymore and the page is good with all data but the problem is when i click "next", all of this data is showed again and it's like i can't go to the next page. why that happen??? is there something wrong with the segment or base url???


Pagination Error (using htaccess) [SOLVED] - El Forum - 08-26-2010

[eluser]tzi0[/eluser]
try this in your routes.cfg:
Code:
$route['admin/joblisting/index/:num']    = "admin/joblisting/index";