With CakePHP, the controller core automatically detects the file name of the view file which needs to be rendered from a controller action. You might want to reuse an existent view for an action or specify a different file name.
For example, if you have a controller named “Users” and you execute a controller action named “profile”, the view file “users/profile.ctp” will be automatically rendered. But you might want to output a view file named “edit.ctp” in the “users” folder. You can do this with the render method.
The code above will automatically render the “users/edit.ctp” view file after the controller action/method has been executed. But say for example that your “edit.ctp” file is not within the “users” folder, but rather inside a folder named “accounts”. Then you can change the viewPath and then execute the render method.
$this -> render(‘edit’);
So the code above will output the “accounts/edit.ctp” view file.







August 22nd, 2008 at 8:34 am
Thanks for your support!
August 26th, 2008 at 3:46 pm
thanks for pointing out, I was looking for that info
September 18th, 2008 at 9:47 pm
Thanks. This is exactly what I am looking for.