有人可以解释“访问参数”在Drupal? [英] Can someone explain "access arguments" in Drupal?

查看:96
本文介绍了有人可以解释“访问参数”在Drupal?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以在Drupal中解释访问参数吗?相信我已经尝试过Google Googling,但我只是没有明确把握。

解决方案

in / admin / user / permissions你将会看到很多访问选项。他们来自drupal模块,并允许站点管理员分配特定权限给用户角色(drupal默认提供匿名和注册角色)。
模块通过 hook_perm 声明它们,它们与:

  function mymodulename_perm {
return array('use custom feature','use the other custom feature');
}

,他们将显示在那里,准备使用。现在,在您的任何功能中,您可以通过 user_access 检查用户访问权限如果(user_access('使用自定义功能')){
// do()),那么可以简单的使用:

 东西
}


Can someone explain "access arguments" in Drupal? Trust me I have tried Googling it but I am just not getting a clear grasp.

解决方案

in /admin/user/permissions you will see lots of access options. they come from drupal modules, and lets the site administrator distribute specific permissions to user roles (drupal provides 'anonymous' and 'registered' roles by default). modules declare them through hook_perm and they are as easy to use as:

function mymodulename_perm {
return array('use custom feature', 'use the other custom feature');
}

and they will show up there, ready to be used. now, in any function of yours, you can check for user access through user_access which is just as easy to use:

if (user_access('use custom feature')) {
  //do something
}

这篇关于有人可以解释“访问参数”在Drupal?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆