开发者

Cake PHP - problem with auth component

开发者 https://www.devze.com 2022-12-20 19:20 出处:网络
My problem is that a variabile is not past from the controller to the view when the user is not logged in, but it is viewable when the user is logged in. My controller method 开发者_运维百科looks like

My problem is that a variabile is not past from the controller to the view when the user is not logged in, but it is viewable when the user is logged in. My controller method 开发者_运维百科looks like this:

function publicprofile( $username ) {
        $user = $this->Users->find('first', array('conditions' => array('username' => $username)));
        $this->set('user', $user['Users']);
    }

The method is in the allowed list and everything works, just that $user is not set.

Thanks


AuthComponent must be overwriting your $user variable in the view. Rename it in your controller like so:

$this->set('myUser', $user['Users']);


$this->set('user', $user['Users']);

should be singular

$this->set('user', $user['User']);
0

精彩评论

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