2011-11-23 62 views
2

我想知道如何将joomla视图中的数据传递给joomla模板。我怎样才能传递多个变量?将joomla视图中的数据传递给joomla中的joomla模板文件1.7

 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); 

    } 
    } 

我想通过$newvar$success_message到模板;我怎么能通过他们?

回答

2

我们可以通过传递视图数据模板:

$var1="Some string"; 
$this->assignRef('var1',$var1); 

请注意,参考assignRef通第二PARAM,我们可以检索它作为

echo $this->var1; 

不仅仅是$var1$this->var1

+0

函数assignRef()在这种情况下定义的视图或模板在哪里? – pal4life