简介:这是CakePHP中的管理员权限的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=336643' scrolling='no'>有时候我们需要一个管理员部分,使部分用户可以进行修改。通常通过
/admin/users/edit/5
这样的链接来实现。在cakePHP中,管理员路由可以在内核配置文件中Routing.admin来设定Configure::write('Routing.admin', 'admin');在你的控制器中,任何一个action以
admin_
开头都能被调用,以users来举例,UsersController
的函数名就会是admin_edit
这样。
你可以使用路由来自定义前缀
Router::connect('/profiles/:controller/:action', array('prefix' => 'profiles'));
任何对profiles的调用都要加上前缀
profiles_
,我们的users例子:/profiles/users/edit/5
将会调用UsersController
的profiles_edit
。请记住,使用html帮助的时候创建链接可以直接用带前缀的函数。下面是个使用HTML 帮助创建链接的例子:
echo $html->link('Edit your profile', array('controller' => 'users', 'action' => 'profiles_edit'));