\AppView

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 view content is rendered first, and then inserted into the selected layout. This also means you can pass data from the view to the layout using $this->set()

Since 2.1, the base View class also includes support for themes by default. Theme views are regular view files that can provide unique HTML and static assets. If theme views are not found for the current view the default app view files will be used. You can set $this->theme = 'mytheme' in your Controller to use the Themes.

Example of theme path with $this->theme = 'SuperHot'; Would be app/View/Themed/SuperHot/Posts

Summary

Methods
Properties
Constants
No public methods found
$Cache
$Form
$Html
$Js
$Number
$Paginator
$Rss
$Session
$Text
$Time
$Blocks
No constants found
_render()
_renderElement()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$Cache

$Cache : \CacheHelper

Type

\CacheHelper

$Form

$Form : \FormHelper

Type

\FormHelper

$Html

$Html : \HtmlHelper

Type

\HtmlHelper

$Js

$Js : \JsHelper

Type

\JsHelper

$Number

$Number : \NumberHelper

Type

\NumberHelper

$Paginator

$Paginator : \PaginatorHelper

Type

\PaginatorHelper

$Rss

$Rss : \RssHelper

Type

\RssHelper

$Session

$Session : \SessionHelper

Type

\SessionHelper

$Text

$Text : \TextHelper

Type

\TextHelper

$Time

$Time : \TimeHelper

Type

\TimeHelper

$Blocks

$Blocks : \ViewBlock

Type

\ViewBlock

Methods

_render()

_render(string  $viewFile, array  $data = array()) : string

Renders and returns output for given view filename with its array of data. Handles parent/extended views.

Parameters

string $viewFile

Filename of the view

array $data

Data to include in rendered view. If empty the current View::$viewVars will be used.

Throws

\CakeException

when a block is left open.

Returns

string —

Rendered output

_renderElement()

_renderElement(string  $file, array  $data, array  $options) : string

Renders an element and fires the before and afterRender callbacks for it and writes to the cache if a cache is used

Parameters

string $file

Element file path

array $data

Data to render

array $options

Element options

Returns

string