Welcome Guest, Not a member yet? Register   Sign In
Handling controller parameters
#4

A (perhaps clumsy) simple way to do this, if you do not know the order of the items in the url, or how many, are coming in on the url is to have something like

PHP Code:
public function edit($option1=FALSE$data1=FALSE$option2=FALSE$data2=FALSE$option3=FALSE$data3=FALSE){

 
  // then deal with the options and data how you want



To interpret the options (and you can do this lots of different ways) you can say something like if option1=order then do_order=TRUE and do_order_type = $data1 ('asc' or 'desc' for example). Or you can run each option through a switch to set the actions to take place and associated rules, or you can call a seperate function on each option which sets them, or you can just repeat the checks for each option. The point is option1 can be 'order', or 'dir' or 'offset' and data1 would be the data associated with that command.

Hope that helps,

Paul.
Reply


Messages In This Thread
Handling controller parameters - by aspz - 07-11-2016, 07:31 AM
RE: Handling controller parameters - by InsiteFX - 07-11-2016, 11:07 AM
RE: Handling controller parameters - by mwhitney - 07-12-2016, 07:35 AM
RE: Handling controller parameters - by PaulD - 07-12-2016, 09:12 AM
RE: Handling controller parameters - by aspz - 07-12-2016, 11:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB