Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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
Drupal:如何显示拒绝访问的菜单项并将其重定向到登录页面_Drupal_Drupal 7_Drupal Modules - Fatal编程技术网

Drupal:如何显示拒绝访问的菜单项并将其重定向到登录页面

Drupal:如何显示拒绝访问的菜单项并将其重定向到登录页面,drupal,drupal-7,drupal-modules,Drupal,Drupal 7,Drupal Modules,我正在使用drupal 7和entity_注册模块(registration-7.x-1.0-alpha5)进行事件注册 此处仅显示特定角色的注册链接,即,如果为经过身份验证的用户设置了权限,则向经过身份验证的用户显示注册链接 如果我们尝试手动访问该页面,例如node/9/register,则显示访问被拒绝 现在,我使用LoginToboggan将拒绝访问页面重定向到用户登录页面。但是,当我手动创建一个名为Register的菜单项时,该菜单项本身没有显示 我想要一种方法,告诉用户登录注册或类似的

我正在使用drupal 7和entity_注册模块(registration-7.x-1.0-alpha5)进行事件注册

此处仅显示特定角色的注册链接,即,如果为经过身份验证的用户设置了权限,则向经过身份验证的用户显示注册链接

如果我们尝试手动访问该页面,例如node/9/register,则显示访问被拒绝

现在,我使用LoginToboggan将拒绝访问页面重定向到用户登录页面。但是,当我手动创建一个名为Register的菜单项时,该菜单项本身没有显示

我想要一种方法,告诉用户登录注册或类似的东西

我希望你明白我的意思

这是模块文件代码。。我认为格式有问题,所以我只粘贴了hook_菜单和hook_权限函数。请访问查看完整代码的链接www.karyashala.in/code.html

    /**

     * Implements hook_menu().

     */

    function registration_menu() {

      $items['registration/%registration'] = array(

        'title callback' => 'registration_page_title',

        'title arguments' => array(1),

        'page callback' => 'registration_view',

        'page arguments' => array(1),

        'access callback' => 'entity_access',

        'access arguments' => array('view', 'registration', 1),

      );

      $items['registration/%registration/view'] = array(

        'title' => 'View',

        'page callback' => 'registration_view',

        'page arguments' => array(1),

        'access callback' => 'entity_access',

        'access arguments' => array('view', 'registration', 1),

        'type' => MENU_DEFAULT_LOCAL_TASK,

      );

      $items['registration/%registration/edit'] = array(

        'title' => 'Edit',

        'page callback' => 'drupal_get_form',

        'page arguments' => array('registration_form', 1),

        'access callback' => 'entity_access',

        'access arguments' => array('update', 'registration', 1),

        'weight' => 10,

        'type' => MENU_LOCAL_TASK,

      );

      $items['registration/%registration/delete'] = array(

        'title' => 'Delete',

        'page callback' => 'drupal_get_form',

        'page arguments' => array('registration_delete_confirm', 1),

        'access callback' => 'entity_access',

        'access arguments' => array('delete', 'registration', 1),

        'type' => MENU_CALLBACK,

      );



      // entity local tasks

      foreach (registration_get_registration_instances() as $instance) {

        $type = $instance['entity_type'];

        if (!in_array($type, array('registration', 'registration_type'))) {

          $items[$type . '/%entity_object/register'] = array(

            'load arguments' => array($type),

            'title' => 'Register',

            'page callback' => 'registration_register_page',

            'page arguments' => array(0, 1),

            'access callback' => 'registration_register_page_access',

            'access arguments' => array(0, 1),

            'type' => MENU_LOCAL_TASK,

          );

          $items[$type . '/%entity_object/registrations'] = array(

            'load arguments' => array($type),

            'title' => 'Manage Registrations',

            'page callback' => 'registration_registrations_page',

            'page arguments' => array(0, 1),



                            'access callback' => 

            'registration_administer_registrations_access',

            'access arguments' => array(0, 1),

            'type' => MENU_LOCAL_TASK,

          );

          $items[$type . '/%entity_object/registrations/list'] = array(

            'load arguments' => array($type),

            'title' => 'Registrations',

            'page callback' => 'registration_registrations_page',


                    'page arguments' => array(0, 1),

            'access callback' => 'registration_administer_registrations_access',


                    'access arguments' => array(0, 1),




                                    'type' => MENU_DEFAULT_LOCAL_TASK,


                  );

          $items[$type . '/%entity_object/registrations/settings'] = array(

            'load arguments' => array($type),

            'title' => 'Settings',

            'page callback' => 'drupal_get_form',

            'page arguments' => array('registration_registrations_settings_form', 0, 
    1),

            'access callback' => 'registration_administer_registrations_access',

            'access arguments' => array(0, 1),

            'weight' => 9,

            'type' => MENU_LOCAL_TASK,

          );

          $items[$type . '/%entity_object/registrations/broadcast'] = array(

            'load arguments' => array($type),

            'title' => 'Email Registrants',

            'page callback' => 'drupal_get_form',

            'page arguments' => array('registration_registrations_broadcast_form', 0, 
    1),

            'access callback' => 'registration_administer_registrations_access',

            'access arguments' => array(0, 1),

            'weight' => 10,

            'type' => MENU_LOCAL_TASK,

          );

        }

      }



      if (module_exists('devel')) {

        $items['registration/%registration/devel'] = array(

          'title' => 'Devel',

          'page callback' => 'devel_load_object',

          'page arguments' => array('node', 1),

          'access arguments' => array('access devel information'),

          'type' => MENU_LOCAL_TASK,

          'file path' => drupal_get_path('module', 'devel'),

          'file' => 'devel.pages.inc',

          'weight' => 100,

        );

        $items['registration/%registration/devel/load'] = array(

          'title' => 'Load',

          'type' => MENU_DEFAULT_LOCAL_TASK,

        );

      }



      return $items;

    }



    /**

     * Implements hook_permission().

    */

    function registration_permission() {

      $permissions = array(

        'administer registration types' => array(

          'title' => t('Administer registration types'),

          'description' => t('Manage registration types, fields, and display 
    settings.'),

          'restrict access' => TRUE,


                ),

        'administer registration' => array(

          'title' => t('Administer registration'),

          'description' => t('View, edit, delete, and manage all registrations, 
    regardless of type.'),

          'restrict access' => TRUE,


                ),

      );



      foreach(registration_get_types() as $type_info) {

        $permissions += registration_permission_list($type_info);

      }




      return $permissions;

    }
Add the line after + sign and clear cache after that check it again.
function registration_menu() {
  $items['registration/%registration'] = array(
    'title callback' => 'registration_page_title',
    'title arguments' => array(1),
    'page callback' => 'registration_view',
    'page arguments' => array(1),
    'access callback' => 'entity_access',
    'access arguments' => array('view', 'registration', 1),
+   'type' => MENU_NORMAL_ITEM,
  );