This project demonstrates how to create a simple page with a Drupal module quickly. It has the following 4 files:
1. simple_page_demo.info - Necessary information of the module.
2. simple_page_demo.module - PHP code.
3. simple_page_1.tpl.php - HTML template for demo page 1.
4. simple_page_2.tpl.php - HTML template for demo page 2.
Enable this module, and demo pages are avaialble at:
http://hostname/demo/simple_page_1
http://hostname/demo/simple_page_2
Basically it uses the hook_menu and hook_theme APIs, code logic can go into the simple_page_1_callback function, while the HTML tags can go into simple_page_1.tpl.php file.
simple_page_2 is especially a demo of page without theme.
Hopes it helps newbies like me in learning Drupal!
Here is the code in simple_page_demo.module:
<?php
/**
* @file
* Create simple pages within this module.
*/
/**
* Implements hook_theme().
*/
function simple_page_demo_theme() {
return array(
'simple_page_1' => array(
'variables' => array(),
'path' => drupal_get_path('module', 'simple_page_demo'),
'template' => 'simple_page_1',
),
'simple_page_2' => array(
'variables' => array(),
'path' => drupal_get_path('module', 'simple_page_demo'),
'template' => 'simple_page_2',
),