Routing and GET parameters

#1
[eluser]stoefln[/eluser]
I love the standard routing mechanism of CI (Controller/Method/Arguments) but what if i have GET parameters which can occur on each page, like lets say a get parameter for paging the comments which can be postet on each page.
each page(method in controller) can have a different number of arguments, so i cant this read this comment_posting_start parameter with e.g. $this->uri->segment(3).
Any ideas?

#2
[eluser]Bramme[/eluser]
Use ajax to paginate them? Just a wild idea though.

#3
[eluser]Thorpe Obazee[/eluser]
I usually use controller/method/keyword/page_number

I get the 'current page' from the URL.

#4
[eluser]stoefln[/eluser]
Ajax is a good idea, but not the one i m searching for.

@chamyto: if you use always 4 segments there is no problem. but i m writing a webapp consisting of different controllers with different methods with different arguments, so the segment for the "comment_posting_start" differs too.

is there maybee a possibility to attach a query parameter like
/controller/method/parmam1/.../paramN/?comment_posting_start=40

#5
[eluser]Bramme[/eluser]
you could add 'commentstart-40' to your uri, and then loop through all your uri segments and check if there's one that has 'commentstart-' in it. If TRUE, cut off commentstart- and you've got your offset.

Not sure how this would affect your performance.

#6
[eluser]stoefln[/eluser]
[quote author="Bramme" date="1220106501"]you could add 'commentstart-40' to your uri, and then loop through all your uri segments and check if there's one that has 'commentstart-' in it. If TRUE, cut off commentstart- and you've got your offset.

Not sure how this would affect your performance.[/quote]

true, but i have to check in each controller method whether the argument contains a "commentstart". would be great if the framework could do this for me.

#7
[eluser]Bramme[/eluser]
You're right... It would be great if you could add parameters not bound to uri segments... However, even if the framework would do it for you, I don't immediatly see another way then to strpos for a certain flag...

Unless you'd add a function add_uri_segment that would log where you put it...

#8
[eluser]m4rw3r[/eluser]
uri_to_assoc() maybe?

Then you use a slash as a separator:
example.com/controller/method/keyword/page/3

#9
[eluser]Bramme[/eluser]
[quote author="m4rw3r" date="1220135841"]uri_to_assoc() maybe?

Then you use a slash as a separator:
example.com/controller/method/keyword/page/3[/quote]
That's a great solution! Just add /comments_page/3 to your uri, wherever you want, use uri_to_assoc and then just check if $array['comments_page'] isset OR ! empty.

#10
[eluser]stoefln[/eluser]
[quote author="Bramme" date="1220140566"][quote author="m4rw3r" date="1220135841"]uri_to_assoc() maybe?

Then you use a slash as a separator:
example.com/controller/method/keyword/page/3[/quote]
That's a great solution! Just add /comments_page/3 to your uri, wherever you want, use uri_to_assoc and then just check if $array['comments_page'] isset OR ! empty.[/quote]

Yes, think thats the best way. Thanks everyone!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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