• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination with Forms

#1
[eluser]Richievc[/eluser]
Hi all new to Code Igniter. Here my question

I expanded the library CI_Pagination to be able to pass a post as segments and and these segment to the link on the Pagination My question is how do I access the segments.

I think I read some where that segments after the 3rd segment can be passed as parameters

But in over all I guess I tring to be able to access the segments via a model to use as a serch query.

Hope this makes sence thx
Richie

#2
[eluser]pickupman[/eluser]
You can access segments using:
Code:
$this->uri->segment(3); //Get third segment
$this->uri->segment(4); //Get forth segment

An alternative method would be passing segments to method:
Code:
function your_method($segment_3 = FALSE, $segment_4 = FALSE){
   echo $segment_3; //third segment
   echo $segment_4; //forth segment
}

Or you can use $this->uri->uri_to_assoc(n) where odd numbered segments will be an array key and even numbered segments will be the array value. You can then use the associative array as you need to. Sometimes in a form, you may not know what the exact order of segments are. So you can use this function to make sense of the pairs.

#3
[eluser]Richievc[/eluser]
Thanks for the fast reply I could not find the $this->uri->uri_to_assoc(n) array but I was able to use $this->uri->segments array then I was able to just check for post and find where in the segment array it sat this is a good quick fix Thanks again.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.