Drupalcamp Gent 2012

Preview:

DESCRIPTION

This session aims to help new drupal developers based on personal experiences and with simple, working examples. Last year, the presenter lost quite some time to get something working. The steap learning curve, new concepts and extensive documentation makes it difficult to improve.

Citation preview

Module Development - Get the Drupal started

Pieter-Jan Drouillon

2

WHYthis talk?

3http://buytaert.net/creating-passionate-users

Time

Ab

ility

Suck

threshold

How soon can they

start kicking ass?Go

od

Bad

4

WHOis talking?

@pjdrouillon | pieterjd.ulyssis.be

DISCLAIMER5

6

DEFINEyour module

Define your module

7

<name>.info file

name

description

core

files

Achmed's advice :)

sites/all/modules/<name>

8

HOOKS

9

When something happens... your module can hook in on it

DEMO

hook_menu

10

FORMS11

DEMOLet’s add a submit function

13

<form_function>_submit($form, &$form_state)

DEMOWhat about ...Validation?

14

<form_function>_validate($form, &$form_state)

BLOCKS15

PERMISSIONS18

PREPROCESS20

21

»

DEMO

hook_form_alter

23

DEMO“I sometimes needa legal disclaimer”

25

Add a checkbox

There’s a catch :)

theming26

DEMO“I want mydefinition list”

Cannot just return html

use theming functions

theme(<hook>,...)

search in API for theme_<hook>

27

DEMOhook_themearray with all the info

key > name of theme (item_list, dd, ...)

add a list of variables

write function to create HTML code

theme_dd($variables)

28

TAKE AWAY29

31

Q & A

Feedback & follow-up:http://drupalcampgent.be/feedback