'Nested' actions in controllers (e.g. /action/sub-action)

Permalink
Hi all

I'm putting together a controller for a single page which passes a different page list to the view depending on the chosen action. At the moment i have these actions:

/scotland
/united-kingdom
/eu

but I'd like to create these too:

/scotland/all
/united-kingdom/all
/eu/all

How is this done in one single controller? Do I need to create a folder structure with further controllers, or is it possible to do this from a single controller for the single page?

I can achieve it using GET variables (e.g. url.com/scotland?v=all) but it's not particularly pretty :)

melat0nin
 
JohntheFish replied on at Permalink Reply
JohntheFish
If you have a scotland action with a single parameter (all=null), then
the paths yourpage/scotland will go to the action with all=null, and yourpage/scotland/all will go to the action with all='all' as a parameter.
melat0nin replied on at Permalink Reply
melat0nin
Ahh I see, does this mean the controller would look like this:


// For /scotland
public function scotland(all = null) {
 ...
}
//For  /scotland/all
public function scotland(all = 'all') {
 ...
}


Is it that simple?

On 28 June 2012 17:40, concrete5 Community <discussions@concretecms.com>wrote:
Mnkras replied on at Permalink Reply
Mnkras
Correct

Sent from my phone
On Jun 28, 2012 1:10 PM, "concrete5 Community" <discussions@concretecms.com>
wrote:
Mnkras replied on at Permalink Reply
Mnkras
public function view($area = null, $all = false) {
}


You can simply add another param to the action, you could also do it like

public function eu($all = false) {
}