如何在Joomla 2.5中将值从控制器传递到视图?

时间:2012-10-30 20:33:27

标签: joomla joomla2.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

1 个答案:

答案 0 :(得分: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年一直在使用的东西,它总是适合我。