I have a UsersController and index() action so by default cakePHP will look for the index.ctp in Users view folder. What i would like to do is to create a separate folder called Partials and have the controller look for the view inside the folder instead. Please help as I just started my journey in cake. Thanks
1
votes
Why do you want to do that?
– 93196.93
Please do response when someone tries to solve your problem or try to help you ...
– Rajeev Ranjan
sorry for late reply i posted the comment when i was about to go out of the office. Yeah my boss is planning to use cakePHP and there is an existing system who does not use the cakePHP naming convension.
– user3454785
1 Answers
3
votes
You can define the path to your view by $this->viewPath
in your controller action. E.g. for the following folder strucuture:
... you can access the various templates by the following statements:
function index()
{
// by code conventions this action automatically matches /Home/index.ctp
$this->viewPath = "/Partials/"; // matches /Partials/index.ctp
$this->render("mypartialview"); // matches /Partials/mypartialview.ctp
}