PHP Класс yii\web\View

View provides a set of methods (e.g. [[render()]]) for rendering purpose. View is configured as an application component in Application by default. You can access that instance via Yii::$app->view. You can modify its configuration by adding an array to your application config under components as it is shown in the following example: ~~~ 'view' => [ 'theme' => 'app\themes\MyTheme', 'renderers' => [ you may add Smarty or Twig renderer here ] ... ] ~~~
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends yii\base\View
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$assetBundles list of the registered asset bundles. The keys are the bundle names, and the values are the registered AssetBundle objects.
$css the registered CSS code blocks.
$cssFiles the registered CSS files.
$js the registered JS code blocks
$jsFiles the registered JS files.
$linkTags the registered link tags.
$metaTags the registered meta tags.
$title the page title

Открытые методы

Метод Описание
beginBody ( ) Marks the beginning of an HTML body section.
clear ( ) Clears up the registered meta tags, link tags, css/js scripts and files.
endBody ( ) Marks the ending of an HTML body section.
endPage ( boolean $ajaxMode = false ) Marks the ending of an HTML page.
getAssetManager ( ) : AssetManager Registers the asset manager being used by this view object.
head ( ) Marks the position of an HTML head section.
registerAssetBundle ( string $name, integer | null $position = null ) : AssetBundle Registers the named asset bundle.
registerCss ( string $css, array $options = [], string $key = null ) Registers a CSS code block.
registerCssFile ( string $url, array $options = [], string $key = null ) Registers a CSS file.
registerJs ( string $js, integer $position = self::POS_READY, string $key = null ) Registers a JS code block.
registerJsFile ( string $url, array $options = [], string $key = null ) Registers a JS file.
registerLinkTag ( array $options, string $key = null ) Registers a link tag.
registerMetaTag ( array $options, string $key = null ) Registers a meta tag.
renderAjax ( string $view, array $params = [], object $context = null ) : string Renders a view in response to an AJAX request.
setAssetManager ( AssetManager $value ) Sets the asset manager.

Защищенные методы

Метод Описание
registerAssetFiles ( string $name ) Registers all files provided by an asset bundle including depending bundles files.
renderBodyBeginHtml ( ) : string Renders the content to be inserted at the beginning of the body section.
renderBodyEndHtml ( boolean $ajaxMode ) : string Renders the content to be inserted at the end of the body section.
renderHeadHtml ( ) : string Renders the content to be inserted in the head section.

Описание методов

beginBody() публичный метод

Marks the beginning of an HTML body section.
public beginBody ( )

clear() публичный метод

Clears up the registered meta tags, link tags, css/js scripts and files.
public clear ( )

endBody() публичный метод

Marks the ending of an HTML body section.
public endBody ( )

endPage() публичный метод

Marks the ending of an HTML page.
public endPage ( boolean $ajaxMode = false )
$ajaxMode boolean whether the view is rendering in AJAX mode. If true, the JS scripts registered at [[POS_READY]] and [[POS_LOAD]] positions will be rendered at the end of the view like normal scripts.

getAssetManager() публичный метод

Registers the asset manager being used by this view object.
public getAssetManager ( ) : AssetManager
Результат AssetManager the asset manager. Defaults to the "assetManager" application component.

head() публичный метод

Marks the position of an HTML head section.
public head ( )

registerAssetBundle() публичный метод

All dependent asset bundles will be registered.
public registerAssetBundle ( string $name, integer | null $position = null ) : AssetBundle
$name string the class name of the asset bundle (without the leading backslash)
$position integer | null if set, this forces a minimum position for javascript files. This will adjust depending assets javascript file position or fail if requirement can not be met. If this is null, asset bundles position settings will not be changed. See [[registerJsFile]] for more details on javascript position.
Результат AssetBundle the registered asset bundle instance

registerAssetFiles() защищенный метод

Removes a bundle from [[assetBundles]] once files are registered.
protected registerAssetFiles ( string $name )
$name string name of the bundle to register

registerCss() публичный метод

Registers a CSS code block.
public registerCss ( string $css, array $options = [], string $key = null )
$css string the content of the CSS code block to be registered
$options array the HTML attributes for the `