开发者

Conditional afterFind based on prefix or page

I have a behavior with an afterFind function that I 开发者_运维百科only want called on a non-admin prefix. $this->params does not work, since $this is referencing the behavior. How can I make this behavior conditional based on the page or prefix?


you can detach (or disable) behavior in the controller:

function beforeFilter(){
  if($this->params['admin'])$this->Model->Behaviors->detach('Foo');
}

http://book.cakephp.org/view/1072/Using-Behaviors

Or you can add your own behavior keyword (like 'contain' for Containable) in the find.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜