Welcome Guest, Not a member yet? Register   Sign In
Pagination Fails After Adding URL Suffix to config.php
#1

[eluser]InvalidCharacter[/eluser]
Hi, yeah, yet another pagination thread. :-S

I'm using CI 2.0.

I had pagination working with the application/config/config.php set to;
Code:
$config['index_page'] = "index.php";
$config['url_suffix'] = "";

The pagination also worked fine after removing index.php with mod_rewrite/htaccess and leaving the suffix blank. It fails whenever I add in a suffix to the URL whether there is $config['index_page'] or not.

Here is the method in the controller that works, which to me looks a little strange because the controller is accepting two vars, but the pagination fails when I add '$page_num' to $config['base_url'] for pagination.
Code:
public function userlist($archive = 1, $page_num = FALSE) {
    // Pagination
    $this->load->library('pagination');
    $config['base_url']     = site_url('admin/users/userlist/'.$archive);
    $config['total_rows']   = $this->users_model->getUserCount($archive);
    $config['per_page']     = $this->config->item('admin_list_length');
    $config['uri_segment']  = 5;
    $config['first_link']   = '<<';
    $config['last_link']    = '>>';
    $config['next_link']    = 'Next';
    $config['prev_link']    = 'Prev';
    $config['num_links']    = 2;
    $this->pagination->initialize($config);
...

With the suffix enabled the URL looks like;
Code:
/index.php/admin/users/userlist/1.ext/5
Without it;
Code:
/index.php/admin/users/userlist/1/5
I tried all sorts of different configs for the pagination changing the 'base_url' and 'uri_segment' but nothing seems to work. The rest of the system works sweet with any of the configs I've tried. It's just the pagination that's failing. >Sad
#2

[eluser]reka[/eluser]
i have same problem :-S
#3

[eluser]LuckyFella73[/eluser]
I'm sure you can handle that by setting up the right routes for that page.
Unfortunately I'm not good with regex stuff so I can't help you directly
to solve that problem ..
#4

[eluser]John_Betong[/eluser]
[quote author="LuckyFella73" date="1287516939"]I'm sure you can handle that by setting up the right routes for that page.
Unfortunately I'm not good with regex stuff so I can't help you directly
to solve that problem ..[/quote]

It looks as though this problem has been overlooked and requires a debug report.

I have just created a partial KLUDGE to overcome the problem.

./system/libraries/Pagination.php
Code:
// round about line 244
// added the following line
$n .= '.html';
$output .= $this->num_tag_open.'<a >anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; and also MY_Pagination.php

Further changes are required for the First and Last links and also a better solution would be to use $CI->config['url_suffix']
&nbsp;
&nbsp;
&nbsp;
#5

[eluser]reka[/eluser]
Quote:It looks as though this problem has been overlooked and requires a debug report.

I have just created a partial KLUDGE to overcome the problem.

./system/libraries/Pagination.php
Code:
// round about line 244
// added the following line
$n .= '.html';
$output .= $this->num_tag_open.'<a >anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; and also MY_Pagination.php

Further changes are required for the First and Last links and also a better solution would be to use $CI->config['url_suffix']
&nbsp;
&nbsp;
&nbsp;
[/quote]



can u tell me the detail,please... coz I don't understan your explanation
#6

[eluser]John_Betong[/eluser]
[quote author="reka" date="1287589027"]
Quote:It looks as though this problem has been overlooked and requires a debug report.

I have just created a partial KLUDGE to overcome the problem.

./system/libraries/Pagination.php
Code:
// round about line 244
// added the following line
$n .= '.html';
$output .= $this->num_tag_open.'<a >anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close; and also MY_Pagination.php

Further changes are required for the First and Last links and also a better solution would be to use $CI->config['url_suffix']
&nbsp;
&nbsp;
&nbsp;
[/quote]



can u tell me the detail,please... coz I don't understan your explanation[/quote]
&nbsp;
&nbsp;
Hi reka,
&nbsp;
When using setting '.config.config.php->config['url_suffix'] it is essential to use $this->load->helper('url')->anchor(...) function in order to get the url_suffixes to work correctly.

The systemlibraries/Pagination.php file does not use the anchor function(). The links use &lt;a href='...'&gt;page_number&lt;/a&gt; format.

The changes I made was a quick Kludge to the library in order to get the Pagination links to work.

Check the library file around line 244 and add the code $n .= '.html';

This line makes the page_number link work but does not fix the First and Last links.

There are only so many hours in the day and the problem is on my Todo list Smile
&nbsp;
&nbsp;
&nbsp;
#7

[eluser]reka[/eluser]
Quote:Hi reka,
&nbsp;
When using setting '.config.config.php->config['url_suffix'] it is essential to use $this->load->helper('url')->anchor(...) function in order to get the url_suffixes to work correctly.

The systemlibraries/Pagination.php file does not use the anchor function(). The links use &lt;a href='...'&gt;page_number&lt;/a&gt; format.

The changes I made was a quick Kludge to the library in order to get the Pagination links to work.

Check the library file around line 244 and add the code $n .= '.html';

This line makes the page_number link work but does not fix the First and Last links.

There are only so many hours in the day and the problem is on my Todo list Smile
&nbsp;
&nbsp;
&nbsp;



now even my url is look like this..... :ohh:

http://localhost/codeigniter/main/all_post.html/5.html
#8

[eluser]reka[/eluser]
thanks John_Betong

my pagination is work right now...

i just change my pagination config...

before :

$config['base_url'] = site_url('main/all_post');

after :

$config['base_url'] = base_url().'main/all_post';

:lol:




Theme © iAndrew 2016 - Forum software by © MyBB