参照书的Hello World模块,功能非常简单,就是显示hello world页面!很适合Drupal 模块开发入门。
在下面的目录当中,
\drupal_site\sites\all\modules\custom\helloworld
创建如下的两个文件:
helloworld.info
name = helloworld
description = A module that just display "Hello World!"
package = Example
core = 7.x
helloworld.module
<?php
/**
* @file
* Main module file for helloworld module.
*/
function helloworld _menu() {
$items['helloworld '] = array(
‘title’ => ‘Greeting’,
'page callback' => 'helloworld ',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Page callback.
*/
function helloworld () {
return t('Hello World!');
}
在Drupal 网站的地址栏当中输入:
%Drupal_Site%/helloworld
就会显示Hello World!页面了。