Drupal. Module developer. Task: Create a properties panel in Admin Control Panel

Well, the module we’re working is HelloWorld. Reference to the last post: Register A New Module

1. Edit [drupal source]\modules\helloworld\helloworld.module

<?php
// $Id: Hello World Module, v0.1 2008/3/17$
/*
 * helloworld_admin: Configuration function.
 */
function helloworld_admin() {
 
  $form['helloworld_SayWhat'] = array(
    '#type' => 'textfield',
    '#title' => t('What do you want to say with the world?'),
    '#default_value' => variable_get('helloworld_SayWhat', "The default say wat"),
    '#size' => 20,
    '#maxlength' => 20,
    '#description' => t("It's not the point. This is just an example about description"),
    '#required' => TRUE,
  );
 
  return system_settings_form($form);
}
/*
 * helloworld_menu: Add the page to hook_menu
 */
function helloworld_menu() {
 
  $items = array();
  $items['admin/settings/helloworld'] = array(
    'title' => 'Helloworld module settings',
    'description' => 'Description of your Helloworld settings control',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('helloworld_admin'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
   );
 
  return $items;
}
?>

2. Enable HelloWorld Module in http://%5Bdrupalsite%5D/admin/build/modules

3. Check the result

http://%5Bdrupalsite%5D/admin/setting/helloworld

Yup.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: