Defining custom pages in your Drupal module is easy using hook_menu and a callback function. Let's have a look at an example.
/**
* Implementation of hook_menu().
*/
function my_module_menu() {
$items['hello'] = array(
'title' => 'Hello world',
'page callback' => 'my_module_page',
'access callback' => TRUE,
);
}
function my_module_page() {
return t('Hello world');
}
In this example, going to /hello will show you a page saying "hello world" rendered using your page template. So this page will display with your logo, blocks, footer, ...
In some cases you don't want this. Mostly in case you won't return HTML but something like XML, JSON, ... Let's have a look at two ways how this can be accomplished.



