// Load the controller $controller = JControllerLegacy::getInstance('MyComponent'); // Set the task to display the view $controller->setTask('display'); // Set the view name $viewName = 'myView'; // Render the view $controller->display($viewName);
// Load the controller $controller = JControllerLegacy::getInstance('MyComponent'); // Set the task to display the view $controller->setTask('display'); // Set the view name $viewName = 'myView'; // Load a model $model = $controller->getModel('MyModel'); // Get some data from the model $data = $model->getData(); // Add the data to the view $controller->getView($viewName)->assign('data', $data); // Render the view $controller->display($viewName);This example loads the controller for the MyComponent component, sets the task to display the view, sets the name of the view, loads a model, gets some data from the model, adds the data to the view and renders the view template. Package Library: Joomla\CMS\MVC\Controller\BaseController.