Created
November 21, 2011 01:26
-
-
Save gavinblair/1381362 to your computer and use it in GitHub Desktop.
Simple Module Development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = Hello World! | |
description = A simple module example | |
core = 7.x | |
version = "7.x-1.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function helloworld_menu(){ | |
$items = array(); | |
$items['hello/world'] = array( | |
'page callback' => 'hello_world_page' | |
); | |
$items['admin/helloworld'] = array( | |
'title' => 'Hello World Admin', | |
'page callback' => 'drupal_get_form', | |
'page arguments' => array('helloworld_admin'), | |
'access arguments' => array('access administration pages') | |
); | |
return $items; | |
} | |
function helloworld_admin(){ | |
$form = array(); | |
$form['helloworld_message'] = array( | |
'#type' => 'textfield', | |
'#title' => "Hello World Message", | |
'#description' => "Message to be displayed", | |
'#required' => TRUE, | |
'#default_value' => variable_get('helloworld_message', "Hello World!"); | |
); | |
return system_settings_form($form); | |
} | |
function hello_world_page(){ | |
return variable_get('helloworld_message', "Hello World!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment