lithium\action\Controller::$_render
Lists the rendering control options for responses generated by this controller.
- The
'type'
key is the content type that will be rendered by default, unless another is explicitly specified (defaults to'html'
). - The
'data'
key contains an associative array of variables to be sent to the view, including any variables created inset()
, or if an action returns any variables (as an associative array). - When an action is invoked, it will by default attempt to render a response, set the
'auto'
key tofalse
to prevent this behavior. - If you manually call
render()
within an action, the'hasRendered'
key stores this state, so that responses are not rendered multiple times, either manually or automatically. - The
'layout'
key specifies the name of the layout to be used (defaults to'default'
). Typically, layout files are looked up as<app-path>/views/layouts/<layout-name>.<type>.php
. Based on the default settings, the actual path would bepath-to-app/views/layouts/default.html.php
. - Though typically introspected from the action that is executed, the
'template'
key can be manually specified. This sets the template to be rendered, and is looked up (by default) as<app-path>/views/<controller>/<action>.<type>.php
, i.e.:path-to-app/views/posts/index.html.php
. - To enable automatic content-type negotiation (i.e. determining the content type of the
response based on the value of the
HTTP Accept header), set the
'negotiate'
flag totrue
. Otherwise, the response will only be based on thetype
parameter of the request object (defaulting to'html'
if no type is present in theRequest
parameters).
Keep in mind that most of these settings may be passed to Controller::render()
as well. To
change how these settings operate (i.e. template paths, default render settings for
individual media types), see the Media
class.
Source
protected $_render = [
'type' => null,
'data' => [],
'auto' => true,
'layout' => 'default',
'template' => null,
'hasRendered' => false,
'negotiate' => false
];