Reputation: 4277
I want to know how can I pass data from joomla view to joomla template. How can I pass multiple variables?
class CareerformViewCareerform extends JView
{
protected $state;
protected $item;
function display($tpl = null)
{
$app = JFactory::getApplication();
$params = $app->getParams();
// Get some data from the models
$state = $this->get('State');
$item = $this->get('Item');
$newvar="Something";
$success_message="Thanks for your interest";
parent::display($tpl);
}
}
I want to pass $newvar
and $success_message
to template; how can I pass them?
Upvotes: 2
Views: 1709
Reputation: 4277
We can pass view data to template by using:
$var1="Some string";
$this->assignRef('var1',$var1);
Please note that assignRef
pass second param by reference and we can retrieve it as
echo $this->var1;
not just $var1
but $this->var1
Upvotes: 2