2

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?

Zeke
  • 1,974
  • 18
  • 33
Hafiz
  • 4,187
  • 12
  • 58
  • 111

1 Answers1

2

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

True Soft
  • 8,675
  • 6
  • 54
  • 83
Hafiz
  • 4,187
  • 12
  • 58
  • 111