I have a controller in my CakePHP app called ‘Profiles’, and this is what my action called index is:
function index($id = NULL) {
$this->set('profile', $this->Profile->findById($id));
}
So using this method to pass in the id, I can then return the correct profile depending on the id that is in the link.
This works fine when I do this on an action called view, however when I try to do it on the index action it treats my id as if it were an action, and returns an error saying that the action doesn’t exist. Is there a way to pass in the id on the index action in CakePHP, or does it have to be on an action besides the index such as a view action?
Cheers,
Adam.
If you want to pass an id to your method you have to visit a url with an id in it.
Cake will load
/profilesas/profiles/indexmagically. You can not use/profiles/<id>out the box, that would require a new Route before it would work.