Create a form with menu on leftside

dileepp - February 3, 2008 - 09:45

Hi,

I am new to CMS and open source. I try to create a form which contains a 5 menus in left. I cant find a details help or step by step note about this. I mean start from the drupal and up to post to a webserver. I tried file API but it I dont get a clear help on it. From where I start an API where to code it? After coding how to connect it with my site? etc. I am new to PHP also but if I get a good help I am sure I can handle the drupal. So please help me by giving atlest on step by step example to create a form and how it is hosted to my webserver. One more doubt is how to create controls in a form?

Thanks
Dileep

Hi dileepp, I faced the

naveenpl - February 9, 2008 - 09:46

Hi dileepp,
I faced the same challenges at first. When you go through some documents and some coding, it all comes down to a clear picture. My suggestion is to go through these documents at first.
http://drupal.org/coding-standards - gives you an idea about coding standards in drupal.
http://drupal.org/node/508 - gives you an idea about how to creat a module and help you to know more about hooks.
http://drupal.org/handbook/modules - these are core modules...

now how to create a menu -
Here 'ModuleName' is the name of your new module and '_menu' is a hook.

<?php
function ModuleName_menu($may_cache) {
   
$menu = array();
    global
$user;
    
$menu[] = array('path' => 'main',
           
'title'=>t('Main Menu'),
           
'description' => t('Main menu which is displayed.'),
           
'position' => 'right',
           
'weight' => 2,
           
'callback' => 'drupal_get_form',
           
'callback arguments' => array('function_name'),
           
'access' => user_access('user'),
        );
   
$menu[] = array('path' =>'main/subone',
           
'title'=>t('Sub Menu1'),
           
'description' => t('First sub menu from main menu. it is default menu(shown when you click the main menu)'),
           
'position' => 'left',
           
'weight' => 1,
           
'type' => MENU_DEFAULT_LOCAL_TASK,
           
'access' => user_access('user'),
    );
   
$menu[] = array('path' => 'main/subtwo',
           
'title'=>t('sub menu2'),
           
'description' => t('second sub menu.'),
           
'position' => 'left',
           
'weight' => 1,
           
'type' => MENU_LOCAL_TASK,
           
'callback' => 'search_member_overview',
           
'access' => user_access('admin'),
    );
   
$menu[] = array('path' => 'main/subthree',
           
'title'=>t('sub menu3'),
           
'description' => t('third sub menu.'),
           
'position' => 'left',
           
'weight' => 1,
           
'type' => MENU_LOCAL_TASK,
           
'callback' => 'search_member_overview',
           
'access' => user_access('admin'),
    );
   
$menu[] = array('path' => 'main/subfour',
           
'title'=>t('sub menu4'),
           
'description' => t('fourth sub menu.'),
           
'position' => 'left',
           
'weight' => 1,
           
'type' => MENU_LOCAL_TASK,
           
'callback' => 'search_member_overview',
           
'access' => user_access('admin'),
    );
   
$menu[] = array('path' => 'main/subfive',
           
'title'=>t('sub menu5'),
           
'description' => t('fifth sub menu.'),
           
'position' => 'left',
           
'weight' => 1,
           
'type' => MENU_LOCAL_TASK,
           
'callback' => 'search_member_overview',
           
'access' => user_access('admin'),
    );
    return
$menu;
?>

I hope this will help you up.
Have fun..

is there a way to move the

SocialNicheGuru - August 11, 2009 - 17:58

is there a way to move the local_tasks to a block which would change depending on what page you are on?

--
Bringing value to the social web by connecting people with events, products, and services that match their interests and values

Code for block creation and

naveenpl - August 20, 2009 - 07:17

Code for block creation and custom links inside block in custom module.
Create block using hook_block like given below

function hook_block($op = 'list', $delta = 0, $edit = array()) {
  global $user;
  if ($op == 'list') {
    $blocks[0]['info'] = t('menu display .');
    return $blocks;
  }
  else if ($delta == 0 && $op == 'view') {
    $block['subject'] = t('block heading');
    $block['content'] = modulename_menu_block();
    return $block;
  }
}
/**
* Function to create block that will display menu listing.
*/
function modulename_menu_block() {
  $items[] = l("title1", "link1t");
  if (user_access('administer access')) {
    $items[] = l("admin link", "node/add/link-to-admin-add");
  }
  $output = theme('node_list', $items);
  return $output;
}

or just create a block the inside php tag use drupal l() function to display link inside that block.

Hope this will help
Naveen P.L.

 
 

Drupal is a registered trademark of Dries Buytaert.