menu有两个来源,一是menu module的数据,另外一个是hook_menu,menu也决定了页面的入口,是一个页面的最基础部分。php
title (string): Menu title
description (string): Menu description
page callback (string): 呈现页面的函数
page arguments (array): page callback所需参数
access callback (boolean|string): 决定页面的访问权限,default: user_access
access arguments (array): access callback的参数
expanded (boolean): menu是否默认展开
type (int): menu的类型,drupal有固定的类型值
weight (int): 权重
file: 加载文件
https://api.drupal.org/api/dr...node
hook_menu应该返回一个函数,每一个key都表明一个URL,如user/%, node/%。key支持特殊的标识符,能够把URL上的参数直接转化为一个对象,如user/%user, node/%node,它们会把URL上的ID值转换为user和node对象再提交到callback处理。api
drupal_get_form函数
user_is_logged_in
user_is_anonymouscode
MENU_CALLBACK : A hidden, internal callback, typically used for API calls.
MENU_DEFAULT_LOCAL_TASK : The "default" local task, which is initially active.
MENU_LOCAL_ACTION : An action specific to the parent, usually rendered as a link.
MENU_LOCAL_TASK : A task specific to the parent item, usually rendered as a tab.
MENU_NORMAL_ITEM : A "normal" menu item that's shown in menu and breadcrumbs.
MENU_SUGGESTED_ITEM : A normal menu item, hidden until enabled by an administrator. orm
https://api.drupal.org/api/dr...对象
$items['some'] = array( 'title' => 'some', 'menu_name' => 'main-menu', 'type' => MENU_NORMAL_ITEM, 'page callback' => 'any', 'access callback' => 'any' ); $items['some/home'] = array( 'title' => 'home page', 'type' => MENU_DEFAULT_LOCAL_TASK, // 若是含有sub menu,就必须有默认页,它与some实际上是同一页,但title会显示在sub menu中 ); $items['some/other'] = array( 'title' => 'other page', 'type' => MENU_LOCAL_TASK, // 会在父级菜单下的TABS出现 'page callback' => 'any' );
$item = array( 'link_title' => 'Links', 'link_path' => 'links', 'menu_name' => 'main-menu', 'plid' => $plid, 'weight' => 2, ); $item['options']['attributes']['title'] = 'My links'; menu_link_save($item);