Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Drupal7自定义模块提供403_Php_Drupal_Drupal 7 - Fatal编程技术网

Php Drupal7自定义模块提供403

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

我的定制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 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()
问题,您的代码非常正确。

很好!我都没注意到,接得好!我甚至没有注意到。