Pages

Wednesday, February 16, 2011

Drupal Module - Primary Menu Tabs

This is the info file of menu_learning.info
name = Learning Menu
description = Learning Menu In Drupal
core = 7.x
version = alpha
package = Learning

While this is the module file: menu_learning.module
<?php

/**
 * Implements hook_menu()
 */
function menu_learning_menu(){
    $items = array();
    $i = 2;
   
    $items['learning/menu'] = array(
        'title' => 'Menu Learning',
        'description' => 'Menu Learning In Drupal Bro',
        'page callback' => 'hey',
        'access callback' => TRUE,
    );
   
    $items['learning/menu/default'] = array(
        'title' => 'Default Menu',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'page callback' => 'hello', // don't need this one
        'access callback' => TRUE,
        'weight' => 1,
    );   
   
    foreach(array('agnes'=>'Agnes Monica','gaga'=>'Lady Gaga', 
                  'luna'=>'Luna Maya') as $key => $value){
        $items['learning/menu/'.$key.''] = array(
            'title' => $value,
            'type' => MENU_LOCAL_TASK,
            'page callback' => 'show_page',
            'page arguments' => array($value),
            'access callback' => TRUE,
            'weight' => $i++,
        );   
    }
       
    return $items;
}

function hey(){
    return t('Holla from indonesia is like for you all here and we wiil do  this one');
}

function hello(){
    return t('You can browse to the tab above.');
}

function show_page($msg){
    return "Hello From $msg! <br/>When you are here,"
          ."we all can do more for this one."
          ."So in the next future, we hope you all get"
          ."want you want.<br/>Thank You.";
}

No comments:

Post a Comment