开发者

CakePHP - Only display a link if user (ARO) has permission for page?

I'm using CakePHP's ACL component to manage permissions for my app. I have about three different "Roles", with different access levels. I am using the HTML helper throughout, to create links to different pages. I would like开发者_如何学运维 links to only display if the user has permission to access the page.

The obvious but cumbersome approach, I guess, would be to set variables to the view containing permissions and show links based on these variables.

I was wondering if there is a better way - perhaps a helper that extends the HTML helper to provide a method that checks permissions first?

Thanks.


I wouldn't recommend to use a helper which has this sort of functionality.

This is because this helper would have to do the checking on every link you use on that page. This would slow down your application.

So I think the best approach is your approach. Set the permission on login and display your links accordingly.
We are using this in our application, too, and it works very good and fast.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜