0

无法理解如何做到这一点。我想在布局(layout/default.ctp)的导航中设置“编辑您的帐户”链接。我想授予登录用户访问权限以仅编辑那里的详细信息(我还将在控制器中处理此问题以检查其当前登录的用户)。但是我如何在布局中做到这一点?

我试过这个但失败了:

<?php echo $this->Html->link('Your Account', array('controller' => 'users', 'action' => 'edit', $this->Auth->users('id')));?>
4

2 回答 2

0

Sorry, I've been over complicating things. To solve this I wrote this in the layout:

<?php echo $this->Html->link('Your Account', array('controller' => 'users', 'action' => 'edit'));?>

and passed the ID in the edit function in the users controller like this

$id = $this->Auth->user('id');
$this->User->id = $id;

Hope this helps someone.

于 2012-08-03T15:45:17.150 回答
0

没有核心身份验证助手。如果那是您自己的,您需要在您的应用控制器中使其全局可用:

public $helpers = array('Auth');
于 2012-08-03T15:28:20.203 回答