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