2011-03-28 59 views
1

我在bootstrap中自動調用動作助手,所以我不需要在動作本身中調用它,它會自動調用。渲染時不會採取行動

在動作助手中,我想要執行渲染,然後停止執行,以使其不像通常那樣進入被調用動作。我應該用什麼來停止執行並阻止它執行?

  • 如果我退出,它不帶我去的動作,但它不會做任何渲染。
  • 如果我回來,它還是到行動(離開動作助手,並繼續和下一步的動作本身,因此執行它)

-

$action = // 
if (/*something*/){ 
    $action->render('second'); 
    return; //it goes to the action after that 
    exit;  //the render doesn't work 
} 
+0

可能:回聲$行動 - >渲染( '第二')?或者你想去其他行動?比你的控制器中$ this - > _ forward('second'); – opHASnoNAME 2011-03-29 05:02:58

回答

1

我會從動作助手返回一個布爾值,然後從那裏渲染。因此,在你的動作助手:

if(/* something */) { 
    $this->_helper->viewRenderer('second.phtml'); 
    return false; 
} else 
    return true; 

而在你的行動:

if($this->_helper->yourHelper()) { 
//Do whatever your action should do otherwise 
} //No need for an else, the render will call second.phtml automatically