I am wondering if CodeIgniter allows segments after the page number and what is the best way to do this?
$config['base_url'] = '/controller/view/pg/';
I need my paging to pass this also:
/controller/view/pg/1/v/l/rpp/20
... etc
I have ran into multiple problems because I am using $this->uri->uri_to_assoc(n)
because of the number of segments I will be needing...
I need to be able to pass values to each page, and at this point I'm not sure how to do it.
Do you think the best way to do this is to always move the paging to the end of all other segments? It seems that this leads to problems also.
Jason, you are making the problem yourself simply because you loose track of what segements are part of the controller/method, and which are your segments that you find relevant.
I would first of all tell you to stick to one method say to append it to the end (this is from the users perspective in the uri, not your route config):
The above format would mean something like this on the backend:
/view/
is the controller,page
is your method in the controller, then you would use$this->uri->uri_to_assoc(4)
(4th element, being name to start).That way you correctly capture your page number
1233
and then all relevant data to it.As a suggestion, I would caution against using unreadable variables, it leads to confusion and does NOT make your site url SEO friendly (who knows what /v/p/123/v/l/20 means in the end?).
Always user your
$this->output->profiler(TRUE);
, if you are having trouble with uri routing. Don't mess with your route config unless you REALLY need to, this may lead to confusion, which complicates your testing.EDIT
I created confusion because based on your question you could interpret it as a routing issue from the position of the config.php file OR the pagination class. I took it from the first approach.
To clarify you need to simply stick to a clean url method, if you use uri_to_assoc, thats fine. But just don't loose track of your page number for the pagination.
You can solve this by making the page number the last element in your uri
Last:
/view/page/1233/name/blue-skies/user/12/20
Where the
20
is the page number that is generated by pagination, the other are segments you use for whatever.You would set your
$config['uri_segment'] = 6;
in this case, and your$config['base_url'] = '/view/page/1233/'.$this->uri->assoc_to_uri($uri_segments);
Where:
IF
It is unknown how many segments you have (say a dynamic $uri_segments array), use
$this->uri->total_segments()
to count total segments, then your pagination one is the +1 to that (last).