CakePHP: Many views – one controller

July 4, 2007 | By | 2 Replies More

If you want multiple controllers to be able to share a view, do this:

  1. Put the shared views in the views/common directory
  2. Call a shared view like this: $this->render(‘../common/view_name’);

Share this post:

Facebooktwittergoogle_pluspinterestlinkedin

Category: CakePHP

Last updated: December 22, 2013

Comments (2)

Trackback URL | Comments RSS Feed

  1. Bill says:

    Thanks, AD, this looks like it will work great when you want all the views for a controller to come from a certain folder. The other way might be more efficient if you want some views to come from the default view folder and some to come from the common folder.

  2. AD7six says:

    … Or
    $this->viewPath = ‘name of view folder’;
    $this->render(‘name of file only’);

    Cheers,

    AD

Leave a Reply