GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Tuesday, February 15, 2011

Hook Menu With Tabs

This is the info file: luna.info
name = Luna Menu
description = Luna Menu Provide Demo For This One
core = 7.x
version = 1.2
package = Lunar

This is the module file: luna.module
<?php
/**
 * Implements hook_menu()
 */
 
function luna_menu(){
    $items = array();
    
    /**
     * The main menu in navigation
     */
    $items['lunar/main'] = array(
        'type' => MENU_NORMAL_ITEM,
        'title' => 'Tabs',
        'page callback' => 'hello',
        'page arguments' => array(t('Holla For You')),
        'access callback' => TRUE,   
    );
    
    /**
     * The first and default displaying tabs
     * Use MENU_DEFAULT_LOCAL_TASK 
     * Add the next ( second) of tabs
     */
    $items['lunar/main/default'] = array(
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'title' => 'Default Tabs',       
        'page callback' => 'holla',
        'weight' => 1,
    );

    /**
     * The second weight menu
     * use MENU_LOCAL_TASK
     * access callback is MUST
     */   
    $items['lunar/main/satu'] = array(
        'type' => MENU_LOCAL_TASK,
        'title' => 'Satu Dimensi',
        'page callback' => 'hey',
        'weight' => 2,
        'access callback' => TRUE,
    );

    $items['lunar/main/dua'] = array(
        'type' => MENU_LOCAL_TASK,
        'title' => 'Dua Dimensi',
        'page callback' => 'indonesia',
        'weight' => 3,
        'access callback' => TRUE,
   
    );
   
    return $items;
}

function hello($msg){
    return $msg;
}

function holla(){
    return t('Default Local Tabs');
}

function hey(){
    return t('Indonesia is a nice one');
}

function indonesia(){
    return t('Malaysia is a nice one for this one');
}

Share/Bookmark

No comments:

Post a Comment