Hello Readers,
The below blog display the data from joomla component controller (C1) to joomla view (V1).
Suppose, we have a data in joomla controller.php and we want to rendered the data in joomla view (for example in component com_mycomponent).
Below, Example code show how to render the data in joomla view.
Step 1 : In Controller use the below code : (com_mycomponent->controller.php)
$view = $this->getView('viewname','format'); //get the view
$view->myVariable = 'Hello'; //set the data to the view
$view->display(); //show the view
Step 2 : In View : (com_mycomponent->views->viewname->view.html.php)
class MycomponentViewItem extends JViewLegacy
{
/** @var string my variable */
public $myVariable;
public function display($tpl = null)
{
$myVariable = $this->myVariable; // use the $view->myVariable variable inside view.html.php.
//...
$this->assignRef( 'myVariable', $myVariable );
}
}
Step 3 : In View : (com_mycomponent->views->viewname->tmpl->default.php)
display the data here :
print_r($this->myVariable); die;
0 Comment(s)