modules
satya - Tuesday, May 31, 2011 4:06:08 PM
read here about the .info file
satya - Wednesday, June 01, 2011 9:57:05 AM
drupal module example menu hook
drupal module example menu hook
satya - Wednesday, June 01, 2011 10:29:01 AM
Here is API 7 hook menu docs
satya - Wednesday, June 01, 2011 10:51:41 AM
First timer mistakes
makesure enable dev modules
remove cache
satya - Wednesday, June 01, 2011 11:15:17 AM
Creating your first module: satya_test_module
The following material will walk you through to create a first module
satya - Wednesday, June 01, 2011 11:15:38 AM
Pick a name: satya_test_module
Pick a name: satya_test_module
satya - Wednesday, June 01, 2011 11:17:06 AM
create a directory for your module
/sites/all/modules/satya_test_module
satya - Wednesday, June 01, 2011 11:17:33 AM
you will need two files underneath
satya_test_module.info
satay_test_module.module
satya - Wednesday, June 01, 2011 11:18:09 AM
satya_test_module.info
core = 7.x
name = Satya Test Module
description = Use this module to muck
version = "7.x-1.0-alpha"
satya - Wednesday, June 01, 2011 11:19:28 AM
satya_test_module.module
<?php
/**
* @file
* A test module to muck
* Created by Satya.
*/
function satya_test_module_help($path, $arg) {
switch ($path) {
case "admin/help#satya_test_module":
return '<p>'. t("Test module") .'</p>';
break;
}
}
function satya_test_module_menu()
{
$items['satyatest'] = array(
'page callback' => 'satya_test_cb1',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
);
return $items;
}
function satya_test_cb1()
{
return t("hello world");
}
Notice the lack of ending tag
satya - Wednesday, June 01, 2011 11:20:18 AM
This file demonstrates
structure of a module
a hook to provide help
a hook to provide a menu
a function to respond to the menu
satya - Wednesday, June 01, 2011 11:21:27 AM
How to test
in modules you should see this module listed
if you click help on the module you should see the help text displayed
if you use the url /satyatest you should see a hello world response
satya - Wednesday, June 01, 2011 11:22:07 AM
http://your-drupal-domain/satyatest
should display the hello world
satya - Wednesday, June 01, 2011 11:22:45 AM
page not found error
if you see this error most likely you will not drop the drupal cache. You can do this by enabling the devel module.
satya - Wednesday, June 01, 2011 11:23:31 AM
php syntax errors
you should see these when you access the drupal domain where this module is enabled.
satya - Wednesday, June 01, 2011 11:24:03 AM
How to enable your module
go to modules and see your module listed and enable it.
satya - Wednesday, June 01, 2011 10:42:05 PM
The help button may show only after enabling the module
either it is coincidental or designed that way but the help menu on the module screen showed up after I have enabled the module.
satya - Wednesday, June 01, 2011 10:42:52 PM
pay attention to the name of the files
for instance i have called the .info file as .inc and it took me a good 10 minutes to see what I was doing wrong
satya - Friday, September 16, 2011 2:22:12 PM
Type of menus
MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be moved/hidden by the administrator.
MENU_CALLBACK: Callbacks simply register a path so that the correct information is generated when the path is accessed.
MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the administrator may enable.
MENU_LOCAL_ACTION: Local actions are menu items that describe actions on the parent item such as adding a new user or block, and are rendered in the action-links list in your theme.
MENU_LOCAL_TASK: Local tasks are menu items that describe different displays of data, and are generally rendered as tabs.
MENU_DEFAULT_LOCAL_TASK: Every set of local tasks should provide one "default" task, which should display the same page as the parent item.
If the "type" element is omitted, MENU_NORMAL_ITEM is assumed.
satya - Friday, September 16, 2011 2:27:48 PM
In drupal how can i control the page title of a menu callback?
In drupal how can i control the page title of a menu callback?
Search for: In drupal how can i control the page title of a menu callback?
satya - Friday, September 16, 2011 2:44:24 PM
How to control the page title
satya - Friday, September 16, 2011 2:44:49 PM
for simple needs you can use
drupal_set_title()
satya - Friday, September 16, 2011 2:55:33 PM
More of my notes on the menu module