A technique that I’m finding quite useful during module development is to create a “stub” function for use as a generic interface callback for menu items that I want to define, but haven’t yet written callbacks for. For example, if I were building a Drupal 5 module called widgetmaster, I would define:
function _widgetmaster_stub($message = "This feature is still
in development.") {
return '<em>'. t($message) .'</em>;
}
So if I’m planning an admin section for my module but haven’t gotten around to implementing it yet, I can at least build out the menu so I (or a client) can click around and make sure the interaction and flow makes sense… for example:
/**
* Implementation of hook_menu().
*/
function widgetmaster_menu($may_cache) {
$items = array();
$access = user_access('access administration pages');
if ($may_cache) {
$items[] = array(
'title' => t('Widgetmaster Settings'),
'path' => 'admin/settings/widgetmaster',
'callback' => '_widgetmaster_stub',
'type' => MENU_NORMAL_ITEM,
'access' => $access
);
$items[] = array(
'title' => t('Overview'),
'path' => 'admin/settings/widgetmaster/overview',
'callback' => '_widgetmaster_stub',
'type' => MENU_DEFAULT_LOCAL_TASK,
'access' => $access
);
$items[] = array(
'title' => t('Advanced'),
'path' => 'admin/settings/widgetmaster/requiredfields',
'callback' => '_widgetmaster_stub',
'type' => MENU_LOCAL_TASK,
'access' => $access
);
}
I can also leave myself specific notes as to what a particular menu callback is supposed to do:
...
$items[] = array(
'title' => t('Advanced'),
'path' => 'admin/settings/widgetmaster/requiredfields',
'callback' => '_widgetmaster_stub',
'callback arguments' => array('Select advanced options from
the widgetmaster_frob table and display as a set of
checkboxes');
'type' => MENU_LOCAL_TASK,
'access' => $access
);
...
Usage needn’t be limited to menu callbacks, either; it’s handy wherever you know you’ll eventually be defining a function that returns a string.
I’m finding it very helpful to have these stub interfaces in place early on in development. It helps fine-tune interaction, and it also serves as a contextual TODO list.


Thats a great technique
This will ensure no errors are return and will help in tracking a large number of menu item which still needs work.
Drupal allows any module to
Drupal allows any module to register callback functions for any URI or a portion of URI. Whilst there's always room for improvement, Drupal and WordPress are both great candidates for dating service platform, they have very distinct niche areas that each should strive in and not try to compete with each other.
Wordpress api allows...
Doesnt wordpress already have these functionalities?
This will ensure no errors
This will ensure no errors are return and will help in tracking a large number of menu item which still needs work.
emo
Post new comment