CodeIgniter Forums
Can I use the normal URL variables structure with CodeIgniter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Can I use the normal URL variables structure with CodeIgniter? (/showthread.php?tid=8493)



Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]KeyStroke[/eluser]
I've been using CodeIgniter for a while, and I noticed that the way it passes the variables in the URL is not flexible at all, and requires extra coding at many parts of the program.

So, is there a way to have some sort of hybrid? something where I can pass variables like this:
Code:
http://example.com/index.php/controller/function/?var1=5&var2=10

If not, then can I just use the original method? if so, then how does it work within CodeIgniter?


Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]mironcho[/eluser]
Hi KeyStroke,
You can use the original query strings by enabling enable_query_strings option in application/config/config.php.
In addition take a look at:

http://codeigniter.com/wiki/QUERY_STRING_GET/
http://ellislab.com/forums/viewthread/56389/


Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]GSV Sleeper Service[/eluser]
you've got two options,

1. turn on query strings - http://ellislab.com/codeigniter/user-guide/general/urls.html
2. pass those parameters as uri segments - http://ellislab.com/codeigniter/user-guide/libraries/uri.html

personally I'd go for the segments method.


Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]KeyStroke[/eluser]
Thanks guys. That will be pretty useful. Smile


Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]Andreas Krohn[/eluser]
If you want to pass things from a form via GET parameters into your app then you can use JavaScript to create the form action URL so it corresponds to the uri segments. Just make a javascript function that is called on the forms onSubmit and that sets location.href for the form, ie
onSubmit="location.href = getSearchFormLocation(); return false;"

In the function do something like:
if (form.myField.value != "") location = "/myFieldName/"+form.myField.value;

Works like a charm.


Can I use the normal URL variables structure with CodeIgniter? - El Forum - 05-20-2008

[eluser]srobet[/eluser]
I'll use the segment method, better look for the url