菜单定义函数hook_menu()
<?php
/**
* Implements hook_menu().
*/
function contact_menu() {
$items['admin/structure/contact'] = array(
'title' => 'Contact form',
'description' => 'Create a system contact form and set up categories for the form to use.',
'page callback' => 'contact_category_list', //列表
'access arguments' => array('administer contact forms'),
'file' => 'contact.admin.inc', //定义管理界面调用函数的文件
);
$items['admin/structure/contact/add'] = array(
'title' => 'Add category',
'page callback' => 'drupal_get_form', //--调用表单
'page arguments' => array('contact_category_edit_form'), //--表单名称
'access arguments' => array('administer contact forms'),
'type' => MENU_LOCAL_ACTION, //7以后新增加的,描述作用于父菜单的动作,呈现动作连接
'weight' => 1,
'file' => 'contact.admin.inc',
);
//--%contact对应contact_load,默认加载
//--编辑的时候对应一个数字
$items['admin/structure/contact/edit/%contact'] = array(
'title' => 'Edit contact category',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_category_edit_form', 4),
'access arguments' => array('administer contact forms'),
'file' => 'contact.admin.inc',
);
$items['admin/structure/contact/delete/%contact'] = array(
'title' => 'Delete contact',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_category_delete_form', 4),
'access arguments' => array('administer contact forms'),
'file' => 'contact.admin.inc',
);
$items['contact'] = array(
'title' => 'Contact',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_site_form'),
'access arguments' => array('access site-wide contact form'),
'type' => MENU_SUGGESTED_ITEM, //--建议类型的菜单,可以开启
'file' => 'contact.pages.inc',
);
$items['user/%user/contact'] = array(
'title' => 'Contact',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_personal_form', 1), //--1代表传递的用户id(%user所在的位置)
'type' => MENU_LOCAL_TASK, //--tab,显示在用户账户管理界面
'access callback' => '_contact_personal_tab_access',//--私有的自定义函数
'access arguments' => array(1),
'weight' => 2, //--权重,可以调整位置
'file' => 'contact.pages.inc',
);
return $items;
}
?>