Welcome Guest, Not a member yet? Register   Sign In
About query strings and alternatives
#1

[eluser]SparkyCola[/eluser]
Hi, I was just wondering... I have a script at the moment, where I use query strings for when someone clicks on a link.

CodeIgniter doesn't like query strings though, so I'm wondering, preferably without getting too long or technical, if there's an obvious work-around.

I just need to be able to say...

If user clicks (link) then:
function1
else if (link2) then:
function2
else
function3.

Does that make sense? Sorry, not good at explaining things... I know that you can enable query strings, but I'm wondering if there's another way of getting that functionality.

Sparky
#2

[eluser]Tom Glover[/eluser]
Quite easily as each segment in the CI url act like a query string in the sense that it can carry data via a link.

Details on:
- CI URLs
- URI Routing
- URI Segments / Class
- URL Helper

Hope This Helps
#3

[eluser]Chris Newton[/eluser]
whatevs.com/index.php/controllername/function1
whatevs.com/index.php/controllername/function2
whatevs.com/index.php/controllername/function3

If you need to use 1 function with multiple values:

whatevs.com/index.php/controllername/function1/value

Then pull it out using the segment

OR

whatevs.com/index.php/controllername/function1/valuename/value1
whatevs.com/index.php/controllername/function1/valuename/value2
if you do something like that, you can use an assoc array for the key/value pair. Since I like key value pairs so much I use this:
http://codeigniter.com/wiki/URI_helper/
#4

[eluser]SparkyCola[/eluser]
Aahhh, I get it. Thanks very much both of you, I thought with the module based nature of CI I must be missing something obvious...and I was Big Grin Thanks for that,

Sparky
#5

[eluser]ScottBruin[/eluser]
I'm partial to the method outlined in the wiki entry below. If you need something more similar to $_GET in that there are optional parameters.

This allows you to have a url like: http://localhost/controller/method1/valu...ame:value2.

I make an array available for my entire controller when I need to use this so I can do $this->request['value1name'];

See: http://codeigniter.com/wiki/alternative_to_GET/




Theme © iAndrew 2016 - Forum software by © MyBB