Sunday, March 23, 2014

How to create a simple custom module in Drupal 7

 follow below the step
Create your first "DataShow" Drupal 7 module with the following steps.
  1. Create a folder called helloworld in sites/all/modules/custom
  2. Create a datashow.info file
  3. Create a template file page-datashow.tpl.php in your theme directory
  4. Enable your module at http://domain.com/admin/build/modules
  5. Visit http://domain.com/datashow
This belongs into your datashow.info file:
; $Id$
 
name = DataShow
description = Bikash ranjan Data Show module
package = Bikash ranjan modules
core = 7.x
 
files[] = datashow.module
The datashow.module file
<?php
 function datashow_menu(){
   $items = array();
 
   $items['helloworld'] = array(
     'title'            => t('Data Show'),
     'page callback'    => 'datashow_output',
     'access arguments' => array('access content'),
   );
 
   return $items;
 }
 
 /*
 * Display output
 */
 function datashow_output() {
   header('Content-type: text/plain; charset=UTF-8');
   header('Content-Disposition: inline');
   return 'datashow';
 }
?>
The theme template file page-datashow.tpl.php
<?php
print $content;
?>