Skip to content

Instantly share code, notes, and snippets.

@gavinblair
Created November 21, 2011 01:26
Show Gist options
  • Save gavinblair/1381362 to your computer and use it in GitHub Desktop.
Save gavinblair/1381362 to your computer and use it in GitHub Desktop.
Simple Module Development
name = Hello World!
description = A simple module example
core = 7.x
version = "7.x-1.0"
<?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