2012-10-30 41 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

相關問題