0% found this document useful (0 votes)
95 views15 pages

Introduction To Module Development

This document provides an overview of Drupal module development. It discusses what modules are and their purpose in Drupal, how and why to create custom modules, module structure and examples, hooks that allow modules to interact with Drupal core, and useful modules and tools for development. Custom modules are created to add new functionality not found in existing core or contributed modules, after ensuring the needed feature does not already exist. The document includes an example of a simple "Hello World" module.

Uploaded by

Denny England
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
95 views15 pages

Introduction To Module Development

This document provides an overview of Drupal module development. It discusses what modules are and their purpose in Drupal, how and why to create custom modules, module structure and examples, hooks that allow modules to interact with Drupal core, and useful modules and tools for development. Custom modules are created to add new functionality not found in existing core or contributed modules, after ensuring the needed feature does not already exist. The document includes an example of a simple "Hello World" module.

Uploaded by

Denny England
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 15

Drupal Module Development

Open Source CMS

Content Management Systems manage website (or intranet) content Open Source Content Management Systems have become one of the real open source success stories The three most popular open source CMS in the nonprofit sector are:

Joomla Drupal Plone

What does a module do?


Core modules provides functionality Contributed modules extends functionality Custom modules defines new functionality
A Custom module is one which is local to your Drupal Project. It's not yet contributed to the contrib repository

Custom Module(When to write)


You need to answer few questions before writing a Custom Module 1. What do you want to achieve by this custom module? 2. Did you search the Contrib Repository to see if a module is already available for that feature? 3. Have you enabled all possible Configurations of the Core & Contrib module to check if they offer you the feature you require?

If your answer is, Yes, I have done enough research and am sure I have to write the code now, then go ahead ....

Custom Module(Why to write)


I need a new feature which is not yet
available in Drupal, and probably can be contributed as a Contrib Module. I don't want to keep adding additional modules to my site for small tweaks, which I can manage in only one custom module for my website. Don't be too much dependent on Contribs.

Examples of modules
Core required modules:
System, Filter, Node, Block, User

Core optional modules:


Taxonomy, Menu, Comment, Search

3rd party modules:


Views, Panels, CCK, Devel

Hooks
Can be thought of as internal Drupal
events Allow modules to interact with the Drupal core Events include:
Creation, deletion of nodes and users Logging in, logging out

Hooks can also create and alter menus


and forms

Hook examples
hook_user
login, logout, insert, view, update

hook_block
view, save, configure, list

hook_form_alter hook_insert hook_comment


insert, update, view, publish, unpublish

Useful modules/tools
Devel (drupal.org/project/devel) Admin Menu
(drupal.org/project/admin_menu) Drush (drupal.org/project/drush) Any others?

Simple Module Structure

Our first module


Hello World module Two files required for a module:
helloworld.info helloworld.module (Optionally) helloworld.install
helloworld

helloworld.info

helloworld.module

Our first module


Where should I put my module? /path_to_drupal/modules /path_to_drupal/sites/all/modules/

helloworld.info
; $Id$ name = Hello World description = Creates a Hello World Content package = Module Dev Training core = 6.x

helloworld.module
<?php function helloworld_perm() { return array(access content); } function helloworld_menu() { $items[My Module'] = array( 'title' => My First Module', 'page callback' => 'display_helloworld', 'access arguments' => array(access content'), 'type' => MENU_NORMAL_ITEM, ); return $items; } function display_helloworld () { return Welcome to my first Drupal Module helloworld; }

Drupal Module Development

ICT Center
We are making IT happen

Integrity

Commitment

Teamwork

You might also like