如何从控制器向其他视图发送数据?
function index()
{
if(!empty($this->data))
{
$projects = $this->Hour->getProjectsByDate($this->data);
**//here I have to redirect $projects to another view.**
}
$this->set('projects', $this->Project->find('list', array('conditions' =>
array('Project.active' => true))));
}
谢谢! :)
答案 0 :(得分:2)
尝试在$this->set('projects', $this->Project->find('list', array('conditions' =>
array('Project.active' => true))));
:
$this->render('whatever view you want');
在渲染不同的视图之前,不要忘记设置变量:
function index()
{
if(!empty($this->data))
{
$projects = $this->Hour->getProjectsByDate($this->data);
**//here I have to redirect $projects to another view.**
//You should set your variables first before you render a different view:
$this->set('projects', $this->Project->find('list', array('conditions' =>
array('Project.active' => true))));
//Then render a different view
$this->render('some other view');
}
}