base\View render()

render() public method

Renders a view.

The view to be rendered can be specified in one of the following formats:

  • path alias (e.g. "@app/views/site/index");
  • absolute path within application (e.g. "//site/index"): the view name starts with double slashes. The actual view file will be looked for under the view path of the application.
  • absolute path within current module (e.g. "/site/index"): the view name starts with a single slash. The actual view file will be looked for under the view path of the current module.
  • relative view (e.g. "index"): the view name does not start with @ or /. The corresponding view file will be looked for under the view path of the view $context. If $context is not given, it will be looked for under the directory containing the view currently being rendered (i.e., this happens when rendering a view within another view).

See also renderFile().

public string render ( $view, $params = [], $context = null )
$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 yii\base\ViewContextInterface, it may also be used to locate the view file corresponding to a relative view name.

return string

The rendering result

throws yii\base\ViewNotFoundException

if the view file does not exist.

throws yii\base\InvalidCallException

if the view cannot be resolved.

doc_Yii
2016-10-30 16:52:35
Comments
Leave a Comment

Please login to continue.