• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding querystrings

#1
[eluser]mattalexx[/eluser]
The problem with the whole "/controller/action/param1value/param2value/param3value" thing is, the parameters do not have keys and so flexibility is lost (what if I wanted to include param3 but not param1 or param2?). It would be cool if I could do something like this:
Code:
/controller/action/param1value/param3key:param3value
Or maybe this:
Code:
/controller/action/param1value?param3key=param3value
What's the best way to include variable parameters without making my life too difficult later on?

#2
[eluser]Randy Casburn[/eluser]
Have you looked at routing? With the ability to use wildcard routing thus:
$route['param3key/:num'] = "yourController/your_param3_method";
$route['param2key/:num'] = "yourController/your_param2_method";
$route['param1key/:num'] = "yourController/your_param1_method";

You can define as many as you need. This provides the flexibility you seek, just with slightly different terminology than you use. I think if you explore this it may work for you.

Randy

#3
[eluser]mattalexx[/eluser]
Thanks for your reply.

#4
[eluser]SeanJA[/eluser]
I usually use

desc1/param1/desc2/param2


Then I use the uri functions to pull the uri out and just see what is in the uri, then I can expand it without having any big rewrites.

#5
[eluser]Colin Williams[/eluser]
Check out $this->uri->uri_to_assoc(n) at http://ellislab.com/codeigniter/user-gui...s/uri.html

#6
[eluser]SeanJA[/eluser]
Exactly! Wink

#7
[eluser]mattalexx[/eluser]
[quote author="Colin Williams" date="1214216681"]Check out $this->uri->uri_to_assoc(n) at http://ellislab.com/codeigniter/user-gui...s/uri.html[/quote]
That's great. Thanks!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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