2012-10-30 38 views
0

我尝试了两种选项(可以找到在互联网),并没有取得进展:如何将价值从控制器传递到在Joomla 2.5中查看?

//in controller 
$show_all = TRUE; 
$view->assignRef('show', $show_all); 
//in default.php and viev.html.php 
$this->show; 
//result 
Notice: Undefined property: componentViewcomponent::$show 


//in controller 
$show_all = TRUE; 
$view->assign('show', $show_all); 
//in default.php and viev.html.php 
$this->get('show'); 
//result 
NULL 
+0

尝试使用“true”或某些可能解决问题的整数值 –

回答

1
$model = $this->getModel('mymodel'); //get the model 
$data_list = $model->getSomeData();//get data from the model 
$view = $this->getView('view_name', 'html'); // get the view 
$view->assignRef('data_list', $data_list); // set the data to the view 
$view->display(); // show the view 

这是我一直在使用什么近1年来,它总是对我的作品。

+0

'$ view-> display();'帮助。非常感谢。 – user1692333

+0

问题出现了。当我试图使用'$ model = $ this-> getModel();'在我看来我得到'注意:未定义的索引:'。这是因为我在控制器中使用你建议的'$ view-> display();'而不是'parent :: display()'。你如何解决这个问题? – user1692333

+0

您必须指定模型的名称。$ this-> getModel('model_name'); – Techie

相关问题