当前位置: 首页 > 工具软件 > Drupal Create > 使用案例 >

Create your first simple Drupal 7 module

公良育
2023-12-01

Create your first Drupal 7 module with the following steps.

  1. Create a folder called helloworld in sites/all/modules/custom
  2. Create a helloworld.info file
  3. Create a template file page-helloworld.tpl.php in your theme directory
  4. Enable your module at http://domain.com/admin/build/modules
  5. Visit http://domain.com/helloworld

This belongs into your helloworld.info file

; $Id$
 
name = helloworld
description = Reinholds Hello World module
package = Reinholds modules
core = 7.x
 
files[] = helloworld.module

The helloworld.module file

<?php
	function helloworld_menu(){
	  $items = array();
 
	  $items['helloworld'] = array(
	    'title'            => t('Hello world'),
	    'page callback'    => 'helloworld_output',
	    'access arguments' => array('access content'),
	  );
 
	  return $items;
	}
 
	/*
	* Display output
	*/
	function helloworld_output() {
	  header('Content-type: text/plain; charset=UTF-8');
	  header('Content-Disposition: inline');
	  return 'helloworld';
	}
?>

The theme template file page-helloworld.tpl.php

<?php
print $content;
?>

转载于:https://my.oschina.net/wangwang110/blog/9571

 类似资料:

相关阅读

相关文章

相关问答