yii\base\View::render PHP Method

render() public method

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).
See also: renderFile()
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 function render($view, $params = [], $context = null)
    {
        $viewFile = $this->findViewFile($view, $context);
        return $this->renderFile($viewFile, $params, $context);
    }

Usage Example

Ejemplo n.º 1
0
 public function render($view, $params = [], $context = null)
 {
     if ($this->id === null) {
         throw new \Exception("The ActiveWindow View 'id' can't be empty!");
     }
     if ($this->module === null) {
         throw new \Exception("The ActiveWindow View 'module' can't be empty!");
     }
     if ($context === null) {
         $context = new \admin\ngrest\base\ViewContext();
         $context->module = $this->module;
         $context->id = $this->id;
     }
     return parent::render($view, $params, $context);
 }
All Usage Examples Of yii\base\View::render