Welcome Guest, Not a member yet? Register   Sign In
Pagination over method parameters not working
#1
Exclamation 
(This post was last modified: 03-18-2015, 07:03 AM by rakibtg.)

Hello CI Community,
i am having problem for the pagination over method parameters.
My routes:
PHP Code:
$route['tag/(:any)'] = 'tag/index/$1'

The pagination works just perfect until i press the next page link!

PHP Code:
$pager['base_url'] = '/tag/'.$tagDetail->slug
this is how i have setup the base url in my tag controller index method but the problem is when i visit the index  method with a parameter then it shows "404 Page Not Found" if you want you can take a look at the production site here > Free People Photo now at the bottom from the pager click on the next page then it shows 404 exception, any idea for this situation?

Edit:
If i add the method name in the pagination's base_url like this
PHP Code:
$pager['base_url'] = '/tag/index/'.$tagDetail->slug.'/'
then the limit query override the limit with the tag slug! Look at the last part of the query:
Code:
... ORDER BY p.date DESC LIMIT people,20
in this query the limit has been replaced by the parameter of the index method of the tag controller! I need help...

Have a great day.
Reply
#2

(This post was last modified: 03-18-2015, 01:05 AM by sajid19991.)

well you said that your pagination is working, but its not (pagination link's on supplied page are throwing 404 error). Post your controller code here so others can take a look and help, im a noob when it comes to routes..
Reply
#3

The below part of documentation may help you fix this issue :
http://www.codeigniter.com/userguide3/in...aining-any
Then, Did you initialize the pagination with $config["uri_segment"] = 3; parameter? (change the segment number according to the url)
Reply
#4

@karthik_code Thanks for your reply. Here is my pagination setup:
PHP Code:
//$pager['base_url'] = '/tag/index/'.$tagDetail->slug.'/';
        
$pager['base_url'] = '/tag/'.$tagDetail->slug.'/';
        
$pager['total_rows'] = 200;
        
$pager['per_page'] = 20;
        
$pager['uri_segment'] = 3;
        
$pager['page_query_string'] = TRUE;
        
$this->pagination->initialize($pager);
        
$page $this->uri->segment(3);
        
/*
        if (empty($page))
        {
            $page = 0;
        }
        */ 
Reply
#5

I have checked your website.
Pages with people tag throws 'No photo' message on page number 4 and above.
This is due to the following hard coded value in the above code.
$pager['total_rows'] = 200;

Dynamically count and set total rows like this.
$pager['total_rows'] = $this->photo_model->count_by_tag($slug);
(You may know this already because other pages programmed perfectly).
Reply
#6

I have solved the problem using a custom hack... Thanks for mentioning counting total rows dynamically
Reply




Theme © iAndrew 2016 - Forum software by © MyBB