Welcome Guest, Not a member yet? Register   Sign In
Can I use the normal URL variables structure with CodeIgniter?
#1

[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?
#2

[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/
#3

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

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

personally I'd go for the segments method.
#4

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

[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.
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB