home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (menu.install)

This example Drupal source code file (menu.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, as, description, em, for, function, links, menu, menu_name, php, the, title, true

The menu.install Drupal example source code

<?php
// $Id: menu.install,v 1.26 2010/08/23 23:38:06 webchick Exp $

/**
 * @file
 * Install, update and uninstall functions for the menu module.
 */

/**
 * Implements hook_schema().
 */
function menu_schema() {
  $schema['menu_custom'] = array(
    'description' => 'Holds definitions for top-level custom menus (for example, Main menu).',
    'fields' => array(
      'menu_name' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Primary Key: Unique key for menu. This is used as a block delta so length is 32.',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Menu title; displayed at top of block.',
        'translatable' => TRUE,
      ),
      'description' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'Menu description.',
        'translatable' => TRUE,
      ),
    ),
    'primary key' => array('menu_name'),
  );

  return $schema;
}

/**
 * Implements hook_install().
 */
function menu_install() {
  $system_menus = menu_list_system_menus();
  $t = get_t();
  $descriptions = array(
    'navigation' => $t('The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.'),
    'user-menu' => $t("The <em>User</em> menu contains links related to the user's account, as well as the 'Log out' link."),
    'management' => $t('The <em>Management</em> menu contains links for administrative tasks.'),
    'main-menu' => $t('The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.'),
  );
  foreach ($system_menus as $menu_name => $title) {
    $menu = array(
      'menu_name' => $menu_name,
      'title' => $t($title),
      'description' => $descriptions[$menu_name],
    );
    menu_save($menu);
  }
}

/**
 * Implements hook_uninstall().
 */
function menu_uninstall() {
  menu_rebuild();
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal menu.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.