Thursday, July 14, 2011

Primary and Secondary Links In Tabs

<?php
Menu Hook:
function sample_menu() {
           $items = array();
           $items['sample'] = array(
           'page callback' => 'drupal_get_form',
           'page arguments' => array('sample_link'),
          'access arguments' => array('access content'),
           'type' => MENU_NORMAL_ITEM,
   );
 
    $items['sample/home'] = array(
        'title' => t('Home'),
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'weight' => -10,
        'access arguments' => array('access content'),
   );
//MENU_LOCAL_TASK, will give the links as Tabs.

   $items['sample/home] = array(
        'title' => 'One',
           'page callback' => 'drupal_get_form',
        'page arguments' => array('one_link'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
         'weight' => -9
   );
 
   $items['sample/home/two'] = array(
        'title' => 'Two',
           'description' => 'Two',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('two_form'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => -8
   );
 
    $items['sample/home/three'] = array(
        'title' => 'Three',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('three_form'),
        'access arguments' => array('access content'),
        'type' => MENU_LOCAL_TASK,
        'weight' => -7
   );
  return $items;
}

/*
 * Primary Link Callback Functions
 */


function sample_link(){
    drupal_set_title("Sample Page");
}

function one_link(){
    drupal_set_title("One Page");
}

/*
 * Secondary Links Callback Functions
 */

function two_form(){

    $form['category'] = array(
    '#type' => 'select',
    '#title1' => t('Category'),
    '#options' => array(
        'project_type' => t('Project Type'),
        'project_sub_type' => t('Project Sub Type'),
        'engagement_type' => t('Engagement Type'),
        'currency' => t('Currency'),
        'role' => t('Role'),
        'location' => t('Location'),
        'skill' => t('Skill'),
        ),
  
    );

      $form['search'] = array(
      '#type' => 'submit',
      '#value' => t('Search'),
      );

return $form;
}


function three_form() {
    $form['emp_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Employee ID'),
  );
    $form['emp_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Employee Name'),
  );
return $form;
}

No comments:

Post a Comment