我正在使用drupal 7和entity_registration模块(registration-7.x-1.0-alpha5)进行事件注册。
仅显示特定角色的注册链接,即如果为经过身份验证的用户设置了权限,则会向经过身份验证的用户显示注册链接。
如果我们尝试手动访问页面,例如node / 9 / register,则显示访问被拒绝。
现在,我已将LoginToboggan重定向访问被拒绝页面用于用户登录页面。但是当我手动创建一个具有路径节点/ 9 /寄存器的命名寄存器菜单项时,菜单项本身不会显示。
我想要一种方法告诉用户登录注册或类似的东西..
我希望你明白我的观点。
这是模块文件代码..我认为格式化有一些问题,所以我只粘贴了hook_menu和hook_permission函数。请访问链接查看完整代码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;
}
答案 0 :(得分:1)
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,
);