2创建相关文件

作者:老葛,北京亚艾元软件有限责任公司,http://www.yaiyuan.com

    我们不妨把模块的名字命名为contactus,在sites/all/modules/custom目录下创建一个contactus目录,接着创建三个文件,contactus.infocontactus.modulecontactus.pages.inc。我们向info文件添加以下内容:

 

name = 联系我们

description = 联系我们页面

core = 7.x

 

    接着,我们向contactus.module中添加hook_menu的实现:

<?php

 

/**

 * @file

 * 方便用户联系我们.

 */

 

/**

 * 实现钩子hook_menu().

 */

function contactus_menu() {

  $items = array();

  //联系我们菜单项

  $items['contactus'] = array(

    'tilte' => '联系我们',

    'page callback' => 'contactus_page',

    'type'     => MENU_CALLBACK,

    'access callback' =>TRUE,

    'file' => 'contactus.pages.inc',

  );

  //确认页面菜单项

  $items['contactus/confirm'] = array(

    'page callback' => 'contactus_confirm_page',

    'type'     => MENU_CALLBACK,

    'access callback' =>TRUE,

'file' => 'contactus.pages.inc',

  );

  //致谢页面菜单项

  $items['contactus/thanks'] = array(

    'page callback' => 'contactus_thanks_page',

    'type'     => MENU_CALLBACK,

    'access callback' =>TRUE,

'file' => 'contactus.pages.inc',

  );

  return $items;

}


Drupal版本: