0
问题是我想调用索引函数,我需要它渲染视图,然后 afterFilter再次重定向到索引函数,并执行相同的操作。像循环一样,问题是它没有渲染它,我尝试使用$ this-> render('index'),但它并不工作,还有其他的事情..CakePhp - 渲染视图+ afterFilter
PS:我没有包括我在索引中的所有代码,因为它没有意义,没有或没有渲染,只是包含了我需要的视图。
function afterFilter()
{
if ($this->params['action'] == 'index')
{
sleep(3);
$this->redirect(array('action'=>'index',$id), null, true);
}
}
THE FUNCTION
function index($ido = 0)
{
$this->set('Operator', $this->Operator->read(null, $ido));
$this->set('ido', $ido);
}
THE VIEW = INDEX.CTP
<legend>Operator StandBy Window</legend>
<?php
?>
</fieldset>
<?php echo $html->link('LogIn', array('controller' => 'operators', 'action' => 'add')); ?>
<?php echo $html->link('LogOut', array('controller' => 'operators', 'action' => 'logout',$ido)); ?>
'$ this-> redirect()'输出一个'Location'标题,将浏览器重定向到一个不同的站点,在这种情况下,在一个循环中。这a)似乎不是一个好主意,并且b)在'afterFilter'中放错了位置。这里真正的目标是什么,为什么你需要循环? – deceze 2010-06-25 07:26:32
为什么不用JavaScript尝试,这很容易... – 2010-06-25 07:30:03
我也会质疑这种功能背后的逻辑,它似乎不合逻辑,并且会导致糟糕的系统设计。 – 2010-06-25 08:53:29