Before diving into the various callbacks, we shall learn the simple but very powerful inheritance rules. We use the parents of a given path for this. For example, the parents of node/%/view
are:
node/%
node
If a page callback is not defined for a path, then we look at the closest parent that has one and use it. If the page callback is inherited from a parent, then the page arguments, the file and the file path are inherited from the parent as a whole, but can be overridden. Most of the time it is only required to overwrite the page arguments and nothing else.
If the page callback is defined for a given path, then nothing is inherited and the page arguments, file, and file path must be defined if they are required.
For example:
$items['admin/user/roles'] = array(
'title' => 'Roles',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_admin_new_role'),
'file' => 'user.admin.inc'
);
$items['admin/user/roles/edit'] = array(
'title' => 'Edit role',
'page arguments' => array('user_admin_role'),
);
The above is shorthand for:
<?php
$items['admin/user/roles'] = array(
'title' => 'Roles',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_admin_new_role'),
'file' => 'user.admin.inc'
);