Simple Query String Handler |
[eluser]virexmachina[/eluser]
After searching through the forums and wiki for a simple way to handle query strings in CI, I ended up writing a simple helper. I only needed to receive a query string on one page, so I didn't want to have to enable hooks, change uri_protocol or anything. This is good for cases where you need to get query strings on a page or two, like a search page or confirmations from payment gateways. Anyway, here's a simple way to access the query string from any controller: Code: // for example, we're calling foo.com/search/?term=foo&bar=goo&baz; I tried to follow CI Input class conventions of returning null for variables that do not exist. I also return true if a var is provided with no value. Download the helper to application/helpers and you're ready to go. I adapted a loop from Dan Horrigan's CodeIgniter Query String hook to look for the query string in a few places. Corrections and suggestions are very welcome. |
Messages In This Thread |
Simple Query String Handler - by El Forum - 01-02-2011, 02:52 PM
Simple Query String Handler - by El Forum - 01-04-2011, 09:36 PM
Simple Query String Handler - by El Forum - 01-05-2011, 09:33 AM
Simple Query String Handler - by El Forum - 01-05-2011, 09:59 AM
Simple Query String Handler - by El Forum - 03-04-2011, 02:49 AM
|