CodeIgniter Forums
Routing issue - Pagination not working properly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Routing issue - Pagination not working properly (/showthread.php?tid=49264)

Pages: 1 2 3


Routing issue - Pagination not working properly - El Forum - 02-13-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
Hello!

I have a controller here:
http://localhost/percutz/news(page 1)
http://localhost/percutz/news/1 (page 1)
http://localhost/percutz/news/2 (page 2)

Controller executes database method from model and returns a result to $data['news'].

No problem at there, but when i go for http://localhost/percutz/news/1 , i have a problem with
Code:
echo $this->pagination;

http://localhost/percutz/news
[1] 2 >
http://localhost/percutz/news/2
1 [2] >

Not showing Last and First and my $config array has $config['first_link'] = 'First New';
and < (previous page).

When i go for http://localhost/percutz/news/index/2 (page 2), pagination shows properly!
http://localhost/percutz/news/2
First New < 1 [2] > Last New


My routes.php
Code:
$routes['news/(:num)'] = 'news/index/$1';


Thanks!


Routing issue - Pagination not working properly - El Forum - 02-13-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
I forgot: i used .htaccess rules for index.php
localhost/percutz/index.php/news.

Is my .htaccess ruining my
Code:
create_links();
?



Routing issue - Pagination not working properly - El Forum - 02-13-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
Any help?
If not, i'm gonna close this topic.
Thanks!


Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
It's now working.
I'm still building my app.
Plase, tell me how can i fix this problem?


Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]InsiteFX[/eluser]
Show your pagination code with your configuration settings.

As far as the first page, if you are on page 1 it will not display the FIRST link tag because you are already on the first page! This is how pagination works...

If you need it displayed then you would need to extend the pagination class.



Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
[quote author="InsiteFX" date="1329251112"]Show your pagination code with your configuration settings.

As far as the first page, if you are on page 1 it will not display the FIRST link tag because you are already on the first page! This is how pagination works...

If you need it displayed then you would need to extend the pagination class.
[/quote]

My config file:
Code:
$config['next_link']  = '&gt;';
$config['prev_link']  = '&lt;';
$config['first_link']  = 'First';
$config['last_link']  = 'Last';
$config['base_url']     = $this->config->item('base_url') . 'news/';

When i go to second page http://localhost/percutz/news/2, i have these links:
1 2 >

I dont have more news and on the page 2, < should be appearing for me.

Obs.: when i put controller method -> http://localhost/percutz/news/index/2 pagination works fine.


Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]InsiteFX[/eluser]
These are the only other 2 config settings that may help you.
Code:
// Number of "digit" links to show before/after the currently viewed page
$config['num_links'] = 4;

// Alternative URL for the First Page.
$config['first_url'] = '';

But like I said if you are on the first page it will display 1 and no < FIRST

Also yoiu should not need to create a route for it, it uses the uri_segment method.

I have modified the CI 2.1.0 Pagination Class to use with Xajax which is what I use along with jQuery.



Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]Aken[/eluser]
Use site_url instead of base_url, especially if your application still uses the index.php file in its URLs, as well as the URI segment for pagination.

Code:
$this->load->helper('url');

// Other config items...
$config['base_url'] = site_url('news');
$config['uri_segment'] = 2;



Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]InsiteFX[/eluser]
@Aken, his url's are working it's not displaying his tags

This controls how many links are shown before and after the current link tag.
Code:
// Number of "digit" links to show before/after the currently viewed page
$config['num_links'] = 4;



Routing issue - Pagination not working properly - El Forum - 02-14-2012

[eluser]Aken[/eluser]
No, his URLs aren't working. That's why when he's on Page 2, it acts like Page 1, unless he includes the index() method.