View (class)

Class View

View, the V in the MVC triad. View interacts with Helpers and view variables passed in from the controller to render the results of the controller action. Often this is HTML, but can also take the form of JSON, XML, PDF's or streaming files.

CakePHP uses a two-step-view pattern. This means that the template content is rendered first, and then inserted into the selected layout. This also means you can pass data from the template to the layout using $this->set()

View class supports using plugins as themes. You can set

public function beforeRender(\Cake\Event\Event $event)
{
     $this->viewBuilder()->theme('SuperHot');
}

in your Controller to use plugin SuperHot as a theme. Eg. If current action is PostsController::index() then View class will look for template file plugins/SuperHot/Template/Posts/index.ctp. If a theme template is not found for the cu