CodeIgniter Forums
Pagination links showing up incorrectly - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Pagination links showing up incorrectly (/thread-53682.html)

Pagination links showing up incorrectly - El Forum - 08-03-2012

Ok, so, I've got a separate cache routine going from CI, (it is working fine and merges with the existing cache system on a site I'm redoing) and I've got hashtag page loading going on with some re-routing (which is also working as expected). What the issue is when the subsequent pages are accessed from the page result, it always shows the pagination link at the last number (as active), although the content of the page is the right content.

public function index($tag,$start='',$end='',$start_pos=0,$limit=20)
  // Load models, scrub date range, etc.

  // this line checks to see if the page is cached, and if it is, just load it
  if (!$data['content']) {
   // gets all articles
   // gets the articles with the page limit applied
   // SITE ROOT is a defined constant
   $config['base_url'] = SITE_ROOT.'/tags/'.$tag."/".$start."/".$end."/";
   $config['total_rows'] = $counter->num_rows();
   $config['per_page'] = $limit;
   $subdata['links'] = $this->pagination->create_links();
   $data['content']=$this->load->view("tags/main_content",$subdata, true);
   $cache->store( "tag_".$tag."_".$start."_".$end."_".$start_pos, $data['content'], "tag_content", $cache_time);
So, the code should store each page in the cache, with the start_pos as the different keys for each of the cache section (this is actually working fine) - however, the pagination links always have the last numbers showing and the last number set to active regardless of what page you're on after the first page loads.

Any ideas? Any other code files needed? (this is a site in the making, it isn't available to view online, I'll provide screenshots and code samples if needed)

Your help is appreciated.

Pagination links showing up incorrectly - El Forum - 08-03-2012

You need to tell the pagination class what page it's on, using the uri_segment config option. The user guide is misleading - it doesn't actually guess the URI segment, it just defaults to a specific one (3).

Pagination links showing up incorrectly - El Forum - 08-07-2012

Thanks, that was it, I was confused because the docs said:

"The pagination function automatically determines which segment of your URI contains the page number."

and I took that to mean it could count the number of segments in the base_url variable and then add one for the pagination location Smile

Pagination links showing up incorrectly - El Forum - 08-07-2012

You're definitely not the only person.