use Joomla\CMS\MVC\View\LegacyView; class MyView extends LegacyView { public function __construct($config = array()) { parent::__construct($config); } } $view = new MyView();
use Joomla\CMS\MVC\View\LegacyView; class MyView extends LegacyView { public function __construct($config = array()) { parent::__construct($config); $this->hello = 'Hello World!'; } } $view = new MyView(array('model' => $model)); echo $view->hello;In this example, we add a custom parameter to the view object called 'hello'. We set its value to 'Hello World!' in the __construct method. We then create a new view object and pass in a model object as a configuration parameter. Finally, we output the value of the 'hello' parameter using echo. Package library: joomla/view