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 [[Application::viewPath|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 [[Module::viewPath|view path]] of the [[Controller::module|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 [[ViewContextInterface::getViewPath()|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).
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 |