Forum
>
Create customize module in drupal 6
Welcome, Guest

Create customize module in drupal 6
Topic Normal Create customize module in drupal 6
by Subhash on 07/18/2009 19:43

A module in drupal 6 has following basic files

1: moduleName.module

2:moduleName.info

3:abc.tpl.php (optional for data rendering purpose

Content of .info file :

//.info starts

; $Id: moduleName.info,v 1.1 2009/01/27 19:59:24 sunsetbill Exp $
name = moduleName
description = Module discription.

; Information added by drupal.org packaging script on 2009-02-03
version = "6.x-1.x"
core = 6.x
datestamp = "1233669018"

//end

//.module content

<?php
// $Id: articleData.module,v 1.2 2009/01/27 22:22:52 sunsetbill Exp $
/**
* @file
* moduleName Module ;
*/
function moduleName_menu() { //hook_menu definition
 $items = array();

 $items['moduleName'] = array(
 'title' => 'Title',
 'page callback' => 'Function_name',
 'access arguments' => array('access content'),

 'type' => MENU_NORMAL_ITEM,
 );

return $items;

}  //hook_block for create a block for module

function moduleName_block($op='list', $delta=0) {
 if ($op == "list") {
 $block[0]['info'] = t('moduleName');
 return $block;
 }
 else if ($op == "view") {
 $path = drupal_get_path('module', 'moduleName');
 $block_content = '';
 $block['content'] = $block_content;
 return $block;
}
}

//calling function body

function function_name() {

$arr = (fetch data from database to be display)

$block_content = theme('abc',$arr); //calling theme function
 return $block_content;

}

function moduleName_theme() {
 return array(
 'abc' => array(
 'template' => 'abc', //abc is the name of tpl by which data will be show
 'arguments' => array('arr'=>nulll),
 ),

);
}