A better way to handle params? |
[eluser]davewilly[/eluser]
Hey guys, I'm finding it a bit of a messy affair dealing with multiple params on a site I'm rebuilding in CI. I have a URL like www.site.com/stag-do/bristol/packages/1 and have been struggling to handle it in a clean manner without some ugly if/elseif. I had thought it would be a case of a nice switch statement. I've had to cascade if/elseif statement, with what I would consider the wrong logical flow to handle it. My psuedo code is this: if a package (ie. /1, /2 etc) param is set ---- Test it in a switch and display package details page elseif packages segment isset and is equal to 'packages' ---- Show the packages page elseif location segment is set, and location segment is equal to 'bristol' and packages segment is not set.. ---- Show location page else ---- 404 I would really appreciate if someone has a better solution. Perhaps this is more of a general PHP questions opposed to a CI specific question! Here is code from my controller, the method I am refering to is bristol() Code: <?php Thanks, Dave |
Messages In This Thread |
A better way to handle params? - by El Forum - 07-30-2010, 05:32 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:07 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:27 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:31 AM
A better way to handle params? - by El Forum - 07-30-2010, 06:38 AM
|