Php Drupal7自定义模块提供403
我的定制drupal 7模块有一些问题。注意,这不是我的第一个模块。这是我的菜单Php Drupal7自定义模块提供403,php,drupal,drupal-7,Php,Drupal,Drupal 7,我的定制drupal 7模块有一些问题。注意,这不是我的第一个模块。这是我的菜单 function blog_contact_menu(){ $items = array(); $items["blog_contact/send_to_one"] = array( "page_callback"=>"single_blogger_contact", "access_arguments"=>array("access blog_contact conte
function blog_contact_menu(){
$items = array();
$items["blog_contact/send_to_one"] = array(
"page_callback"=>"single_blogger_contact",
"access_arguments"=>array("access blog_contact content"),
"type"=>MENU_CALLBACK
);
return $items;
}
这是我的烫发功能
function blog_contact_perm() {
return array("access blog_contact content");
}
这应该可以工作,但当我调用ajax时,它会给出403。您无权查看bla bla。我的ajax调用正确且简单,url正确,类型为post。我没有直接看到原因。由于您没有在
hook\u菜单实现中指定,它默认使用该功能,并检查您是否已授予access blog\u contact content
权限
function blog_contact_menu(){
$items = array();
$items["blog_contact/send_to_one"] = array(
// As mentioned in Clive's answer, you should provide a title
"title" => "Your Title goes here",
"page callback"=>"single_blogger_contact",
// No "access callback" so uses user_access function by default
"access arguments"=>array("access blog_contact content"),
"type"=>MENU_CALLBACK
);
access blog\u contact content
不是Drupal知道的权限,因此user\u access
函数返回false,这就是403访问被拒绝的原因
如果您想告诉Drupal关于access blog\u contact content
权限的信息,那么钩子是,而不是hook\u perm
您的代码应该更像:
function blog_contact_permission() {
return array(
'access blog_contact content' => array(
'title' => t('Access blog_contact content'),
'description' => t('Enter your description here.'),
),
);
}
由于您没有在hook\u菜单
实现中指定,它默认使用该功能,并检查您是否已授予access blog\u contact content
权限
function blog_contact_menu(){
$items = array();
$items["blog_contact/send_to_one"] = array(
// As mentioned in Clive's answer, you should provide a title
"title" => "Your Title goes here",
"page callback"=>"single_blogger_contact",
// No "access callback" so uses user_access function by default
"access arguments"=>array("access blog_contact content"),
"type"=>MENU_CALLBACK
);
access blog\u contact content
不是Drupal知道的权限,因此user\u access
函数返回false,这就是403访问被拒绝的原因
如果您想告诉Drupal关于access blog\u contact content
权限的信息,那么钩子是,而不是hook\u perm
您的代码应该更像:
function blog_contact_permission() {
return array(
'access blog_contact content' => array(
'title' => t('Access blog_contact content'),
'description' => t('Enter your description here.'),
),
);
}
菜单项中的属性中有空格而不是下划线<代码>访问参数
实际上应该是访问参数
,页面参数
应该是页面参数
,等等:
function blog_contact_menu(){
$items = array();
$items["blog_contact/send_to_one"] = array(
"title" => "Title",
"page callback"=>"single_blogger_contact",
"access arguments"=>array("access blog_contact content"),
"type"=>MENU_CALLBACK
);
return $items;
}
还要注意,title
是必需的属性
除此之外,还有前面提到的
hook\u permission()
问题,您的代码非常正确。菜单路由器项中的属性中有空格,而不是下划线<代码>访问参数实际上应该是访问参数
,页面参数
应该是页面参数
,等等:
function blog_contact_menu(){
$items = array();
$items["blog_contact/send_to_one"] = array(
"title" => "Title",
"page callback"=>"single_blogger_contact",
"access arguments"=>array("access blog_contact content"),
"type"=>MENU_CALLBACK
);
return $items;
}
还要注意,title
是必需的属性
除此之外,还有前面提到的
hook\u permission()
问题,您的代码非常正确。很好!我都没注意到,接得好!我甚至没有注意到。