Adding Menus to a Drupal Module
I’ve heard a lot about Drupal but hadn’t yet used it for anything. That changed when a friend approached me for help in developing a custom content type module for his drupal site. The content type required some custom processing on submitting and for viewing so CCK was not an option.
A lot of Googling and poring through drupal site most of what I wanted was here
The creation of the content type module went quick and easy making me learn to love Drupal.
But then came time to add some admin side settings and functions for the module and search after search lead me in circles while I tried to add links to the admin side functionality of the module.
Page after page of help resulted in no links being added although I could access my modules functions by going to the appropriate url ['admin/settings/mynewmodule'] I spend hours searching and trying to get the links to appear as they should.
Caching seemed like a probable cause even though I had no caching enabled I figured out shortly on other problems that clearing the cache would solve the problem. But of course this didn’t help here.
Eventually I found a post that said the menus would not be updated until you visited /admin/build/modules . If the tutorials, examples and ebooks I had spent so much time reading had mentioned this … (I lost the link to the answer that finally solved my problem)
I’m really liking drupal and the tons (almost to much lots of copies of the same documentation) of documentation on it but the documentation still lacks some basic info required to do a beginner any good.
An Bad Example:
$items['admin/mymodule/notify'] = array(
'title' => 'My Module Function',
'page callback' => 'my_module_notify',
'access arguments' => array('administer users'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/mymodule'] = array(
'title' => 'My Module Settings',
'description' => ''My Module Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('mymodule_admin'),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array('administer users'),
);
?>
While this sample may be technically correct it fails to tell you what file or function this goes into. (mymodule.module) or that after creating a menu item you should visit the modules listing page to recognize the modules use of the menu hook.
Compared to Joomla it is fairly easy to develop fairly complex sites in Drupal, once you get through the initial hoops of not quite there documentation.