Creating Custom Drupal Modules
Upcoming SlideShare
Loading in...5
×
 

Creating Custom Drupal Modules

on

  • 17,453 views

Presentation delivered to the East Anglia Drupal Usergroup meeting on 16th June 2010 demonstrating how to create a simple custom module in Drupal 7.x

Presentation delivered to the East Anglia Drupal Usergroup meeting on 16th June 2010 demonstrating how to create a simple custom module in Drupal 7.x

Statistics

Views

Total Views
17,453
Views on SlideShare
17,435
Embed Views
18

Actions

Likes
4
Downloads
257
Comments
1

4 Embeds 18

https://auroraearth.atlassian.net 11
http://192.168.2.143 4
http://localhost 2
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • really infomative..ease of understanding...
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Creating Custom Drupal Modules Creating Custom Drupal Modules Presentation Transcript

    • Creating Custom Drupal Modules Drupal East Anglia UG – 16/6/2010 Alastair Aitchison
      • Independent developer based in Norwich
      • 3 years Drupal experience
      • Current maintainer of Question module
      • Contributed to Automatic Nodetitles , Node Import , Examples , Synonyms , Tagadelic , WebSnapr ...
      • tanoshimi AlastairA [email_address]
      About Me
    • Types of Module
    • Anatomy of a Module
      • Required
      • .info – metadata describing the module
      • .module – the module PHP code
      • Optional
      • .install – install / uninstall scripts
      • .css – stylesheets
      • .inc – additional include files
      • .test – unit test files
    • Where Do Module Files Reside?
      • CORE
      • /modules/ subdirectory
      • Don’t edit or place other modules here!
      • CONTRIB & CUSTOM
      • /sites/all/modules/ subdirectory
      • Directory name matches module name
    • .info file
      • Metadata about the module
      • Name, description, version, dependencies etc.
      • EXAMPLE!
    • meeting.info
      • name = Meeting Demo Module
      • description = This is a demo module
      • for the Drupal UG meeting
      • core = 7.x
      • version = 7.0 - alpha
      • files[] = meeting.module
    • Drupal’s Hook System Build menus Render node Build blocks hook_menu hook_node_view
    • .module file
      • Implements one or more Drupal hooks – PHP functions that get called by Drupal
      • Proper naming ensures that functions are automatically recognised and fired at the right time
      • Syntax is modulename_hookname
      • EXAMPLE!
    • meeting.module
      • <?php
      • function meeting_menu() {
      • $items['meeting_page'] = array(
      • 'title' => 'My newmenu item',
      • 'description' => 'This is a test menu item',
      • 'page callback' => 'meeting_page',
      • 'access callback' => TRUE,
      • );
      • return $items;
      • }
      • function meeting_page() {
      • return 'Yay! This worked.... probably.';
      • }
    • Altering Other Modules
      • Edit user_login_form? (l. 1,154 of user.module)
      • Use hook_form_ user_login_form _alter
      How to change this? NO! YES!
    • Alter Hooks Build menus Render node Build blocks Perform Alterations hook_menu hook_node_view hook_xxx_alter
    • Not only forms can be altered...
      • hook_link_alter
      • hook_mail_alter
      • hook_menu_alter
      • hook_profile_alter
      • hook_schema_alter
      • ...
    • More Resources
      • http://api.drupal.org – lists all available hooks, together with example usage
      • http://drupal.org/project/modules - contrib module repository
      • http://www.apress.org – publishers of Pro Drupal Development
    • Things to Remember
      • Custom modules add new functionality / alter other modules by implementing hooks
      • Require .info (metadata) and .module (code)
      • Create in a subdirectory of sites/all/modules
      • DON’T EDIT CORE! Use hook_xxx_alter