URL 当我授予模块权限时点击显示不需要的输出
URL hit showing output didn't want when I give permission to the module
直接URL点击它显示结果我不想这样做但是当我允许它时它应该可以正常工作。帮助我解决这个问题,我将非常感谢你。
这是我的模块,请提供该模块的代码:
<?php
// $Id: person.module
/**
* implements hook_menu()
*/
function person_menu(){
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "perso_personal_info", // after visit drupal6/person, person_personal_info() function is called
'access callback' => true, // must return true, otherwise it will not visible as menu item
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
function perso_personal_info(){
$output = 'Name: Gaurav</br>';
$output .= 'City: nanital </br>';
$output .= 'Country: india </br>';
return $output;
}
function person_permission(){
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
); }
?>
请提供我需要的代码;当我为我的模块设置权限时它应该可以正常工作。
您需要在 hook_menu 中更新 "access callback",其中将按如下方式检查用户权限:
/**
* implements hook_menu()
*/
function person_menu() {
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "demo_custom_personal_info", // after visit drupal6/person, person_personal_info() function is called
//'access callback' => true, // must return true, otherwise it will not visible as menu item
'access callback' => 'person_personal_info_check_access',
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
现在您需要在模块文件中添加以下功能(此功能将检查用户的访问权限,该权限将从权限页面分配)
/**
* To check user's permission
*/
function person_personal_info_check_access() {
if (user_access('administer my module')) {
return TRUE;
}
return FALSE;
}
直接URL点击它显示结果我不想这样做但是当我允许它时它应该可以正常工作。帮助我解决这个问题,我将非常感谢你。
这是我的模块,请提供该模块的代码:
<?php
// $Id: person.module
/**
* implements hook_menu()
*/
function person_menu(){
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "perso_personal_info", // after visit drupal6/person, person_personal_info() function is called
'access callback' => true, // must return true, otherwise it will not visible as menu item
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
function perso_personal_info(){
$output = 'Name: Gaurav</br>';
$output .= 'City: nanital </br>';
$output .= 'Country: india </br>';
return $output;
}
function person_permission(){
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
); }
?>
请提供我需要的代码;当我为我的模块设置权限时它应该可以正常工作。
您需要在 hook_menu 中更新 "access callback",其中将按如下方式检查用户权限:
/**
* implements hook_menu()
*/
function person_menu() {
$items = array();
$items['person'] = array(
'title' => "Person",
'page callback' => "demo_custom_personal_info", // after visit drupal6/person, person_personal_info() function is called
//'access callback' => true, // must return true, otherwise it will not visible as menu item
'access callback' => 'person_personal_info_check_access',
'type' => MENU_NORMAL_ITEM, // drupal's default menu type
'weight' => '10', // we want to display person link below in our nav menu
);
return $items; // finally, do not forget to return $items array
}
现在您需要在模块文件中添加以下功能(此功能将检查用户的访问权限,该权限将从权限页面分配)
/**
* To check user's permission
*/
function person_personal_info_check_access() {
if (user_access('administer my module')) {
return TRUE;
}
return FALSE;
}