CakePHP 2.x - Custom Routes

I have two controllers: ArtistsController and RecordsController

I want to order routes logically depending on what the user is doing.

In this case once the user is editing an Artist (/artists/edit/some-artist) he's able to add some records for that artist.

So, I'd like the route to be something like: "/artists/edit/some/artist/records/add"

And the same thing with the editing function of a record: "/artists/edit/some-artist/records/edit/some-record"

I've been fighting with it for a while but I've never worked with Routes before on CakePHP and can't find a solution for this. Is this possible? Thanks


In Config/routes.php

Router::connect('/artists/edit/:some_artist', array('controller' => 'artists', 'action' => 'edit'), array('pass' => array('some_artist')));
Router::connect('/artists/edit/:some_artist/:records', array('controller' => 'artists', 'action' => 'edit'), array('pass' => array('some_artist','records')));

and you go on depending how what parameters you want to pass.

rule is simple: is some variable needs to be passed you put colon ":" before it, and add its name in array 'pass'.

I suggest read Routing: Route elements if you want specify type of passing element.

Additionally Artists Controller function should like this

public function edit($some_artist=null,$records = null) {

Need Your Help

DataReader with parametrs;

c# mysql dataset datareader

I am currently struggling with MySQL database with DataSet. The thing is that it uses loads of memory(as I found somewhere over the net it uses almost 4x memory rather than when you are using DataR...

How to query my tables to give data in such a format?

mysql sql orm

I have developed a structure to represent hierarchical data in in my db. Now I have 3 tables with relationship defined with each one.