Property | Type | Description | |
---|---|---|---|
$blocks | a list of named output blocks. The keys are the block names and the values are the corresponding block content. You can call View::beginBlock and View::endBlock to capture small fragments of a view. They can be later accessed somewhere else through this property. | ||
$cacheStack | a list of currently active fragment cache widgets. This property is used internally to implement the content caching feature. Do not modify it directly. | ||
$context | the context under which the View::renderFile method is being invoked. | ||
$defaultExtension | the default view file extension. This will be appended to view file names if they don't have file extensions. | ||
$dynamicPlaceholders | a list of placeholders for embedding dynamic contents. This property is used internally to implement the content caching feature. Do not modify it directly. | ||
$params | custom parameters that are shared among view templates. | ||
$renderers | a list of available renderers indexed by their corresponding supported file extensions. Each renderer may be a view renderer object or the configuration for creating the renderer object. For example, the following configuration enables both Smarty and Twig view renderers: php [ 'tpl' => ['class' => 'yii\smarty\ViewRenderer'], 'twig' => ['class' => 'yii\twig\ViewRenderer'], ] If no renderer is available for the given view file, the view file will be treated as a normal PHP and rendered via View::renderPhpFile. | ||
$theme | the theme object or the configuration for creating the theme object. If not set, it means theming is not enabled. |
Method | Description | |
---|---|---|
addDynamicPlaceholder ( string $placeholder, string $statements ) | Adds a placeholder for dynamic content. | |
afterRender ( string $viewFile, array $params, string &$output ) | This method is invoked right after View::renderFile renders a view file. | |
beforeRender ( string $viewFile, array $params ) : boolean | This method is invoked right before View::renderFile renders a view file. | |
beginBlock ( string $id, boolean $renderInPlace = false ) : |
Begins recording a block. | |
beginCache ( string $id, array $properties = [] ) : boolean | Begins fragment caching. | |
beginContent ( string $viewFile, array $params = [] ) : yii\widgets\ContentDecorator | Begins the rendering of content that is to be decorated by the specified view. | |
beginPage ( ) | Marks the beginning of a page. | |
endBlock ( ) | Ends recording a block. | |
endCache ( ) | Ends fragment caching. | |
endContent ( ) | Ends the rendering of content. | |
endPage ( ) | Marks the ending of a page. | |
evaluateDynamicContent ( string $statements ) : mixed | Evaluates the given PHP statements. | |
getViewFile ( ) : string | boolean | ||
init ( ) | Initializes the view component. | |
render ( string $view, array $params = [], object $context = null ) : string | Renders a view. | |
renderDynamic ( string $statements ) : string | Renders dynamic content returned by the given PHP statements. | |
renderFile ( string $viewFile, array $params = [], object $context = null ) : string | Renders a view file. | |
renderPhpFile ( string $_file_, array $_params_ = [] ) : string | Renders a view file as a PHP script. |
Method | Description | |
---|---|---|
findViewFile ( string $view, object $context = null ) : string | Finds the view file based on the given view name. |
public addDynamicPlaceholder ( string $placeholder, string $statements ) | ||
$placeholder | string | the placeholder name |
$statements | string | the PHP statements for generating the dynamic content |
public afterRender ( string $viewFile, array $params, string &$output ) | ||
$viewFile | string | the view file being rendered. |
$params | array | the parameter array passed to the [[render()]] method. |
$output | string | the rendering result of the view file. Updates to this parameter will be passed back and returned by [[renderFile()]]. |
public beginBlock ( string $id, boolean $renderInPlace = false ) : |
||
$id | string | the block ID. |
$renderInPlace | boolean | whether to render the block content in place. Defaults to false, meaning the captured block will not be displayed. |
return | the Block widget instance |
public beginCache ( string $id, array $properties = [] ) : boolean | ||
$id | string | a unique ID identifying the fragment to be cached. |
$properties | array | initial property values for [[FragmentCache]] |
return | boolean | whether you should generate the content for caching. False if the cached version is available. |
public beginContent ( string $viewFile, array $params = [] ) : yii\widgets\ContentDecorator | ||
$viewFile | string | the view file that will be used to decorate the content enclosed by this widget. This can be specified as either the view file path or path alias. |
$params | array | the variables (name => value) to be extracted and made available in the decorative view. |
return | yii\widgets\ContentDecorator | the ContentDecorator widget instance |
public evaluateDynamicContent ( string $statements ) : mixed | ||
$statements | string | the PHP statements to be evaluated. |
return | mixed | the return value of the PHP statements. |
protected findViewFile ( string $view, object $context = null ) : string | ||
$view | string | the view name or the path alias of the view file. Please refer to [[render()]] on how to specify this parameter. |
$context | object | the context to be assigned to the view and can later be accessed via [[context]] in the view. If the context implements [[ViewContextInterface]], it may also be used to locate the view file corresponding to a relative view name. |
return | string | the view file path. Note that the file may not exist. |
public getViewFile ( ) : string | boolean | ||
return | string | boolean | the view file currently being rendered. False if no view file is being rendered. |
public render ( string $view, array $params = [], object $context = null ) : string | ||
$view | string | the view name. |
$params | array | the parameters (name-value pairs) that will be extracted and made available in the view file. |
$context | object | the context to be assigned to the view and can later be accessed via [[context]] in the view. If the context implements [[ViewContextInterface]], it may also be used to locate the view file corresponding to a relative view name. |
return | string | the rendering result |
public renderDynamic ( string $statements ) : string | ||
$statements | string | the PHP statements for generating the dynamic content. |
return | string | the placeholder of the dynamic content, or the dynamic content if there is no active content cache currently. |
public renderFile ( string $viewFile, array $params = [], object $context = null ) : string | ||
$viewFile | string | the view file. This can be either an absolute file path or an alias of it. |
$params | array | the parameters (name-value pairs) that will be extracted and made available in the view file. |
$context | object | the context that the view should use for rendering the view. If null, existing [[context]] will be used. |
return | string | the rendering result |
public $blocks |
public $cacheStack |
public $context |
public $defaultExtension |
public $dynamicPlaceholders |
public $renderers |