13 6 / 2011

Send multiple records AND any related controllers to the view in CakePHP 1.3

This isn’t something particularly hard to figure out, but I was using the wrong search terms to help me figure this one out so it took me longer than it should have. Hopefully this will be of use to someone else, if just to explain it slightly differently. Recognise this snippet:

function index() {
    $this->Controller->recursive = 0;
    $this->set('controllers', $this->paginate());
}
Simply change “$this->Controller->recursive = 0;” to:
$this->Controller->recursive = 1;
This returns an array with nodes for each of the controllers related to the controller you’re using.