开发者

Cake PHP - problem with auth component

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜