tra*_*nte 6 cakephp before-filter cakephp-2.0
在我的CakePHP 2应用程序中,我遇到了beforeFilter的问题.在这个线程中它运作良好.因为CakePHP的旧版本.
在我的代码中,如果用户未获得授权,我想向他显示"anotherview.ctp".我不想将访问者重定向到另一个页面.(因为adsense问题)
当我在beforeFilter中使用"this-> render"时,我的"索引"动作中的代码也会运行.我想在"beforeFilter"的最后一行之后停止执行.当我将"exit()"添加到beforeFilter时,它破坏了我的代码.
如何在不破坏代码的情况下在beforeFilter中停止执行?
class MyController extends AppController {
function beforeFilter() {
if ( $authorization == false ) {
$this->render('anotherview');
//exit();
}
}
}
function index() {
// show authorized staff
}
}
Run Code Online (Sandbox Code Playgroud)