32
Module Development - Get the Drupal started Pieter-Jan Drouillon

Drupalcamp Gent 2012

Embed Size (px)

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

Page 1: Drupalcamp Gent 2012

Module Development - Get the Drupal started

Pieter-Jan Drouillon

Page 2: Drupalcamp Gent 2012

2

WHYthis talk?

Page 3: Drupalcamp Gent 2012

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

Time

Ab

ility

Suck

threshold

How soon can they

start kicking ass?Go

od

Bad

Page 4: Drupalcamp Gent 2012

4

WHOis talking?

@pjdrouillon | pieterjd.ulyssis.be

Page 5: Drupalcamp Gent 2012

DISCLAIMER5

Page 6: Drupalcamp Gent 2012

6

DEFINEyour module

Page 7: Drupalcamp Gent 2012

Define your module

7

<name>.info file

name

description

core

files

Achmed's advice :)

sites/all/modules/<name>

Page 8: Drupalcamp Gent 2012

8

HOOKS

Page 9: Drupalcamp Gent 2012

9

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

Page 10: Drupalcamp Gent 2012

DEMO

hook_menu

10

Page 11: Drupalcamp Gent 2012

FORMS11

Page 13: Drupalcamp Gent 2012

DEMOLet’s add a submit function

13

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

Page 14: Drupalcamp Gent 2012

DEMOWhat about ...Validation?

14

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

Page 15: Drupalcamp Gent 2012

BLOCKS15

Page 18: Drupalcamp Gent 2012

PERMISSIONS18

Page 20: Drupalcamp Gent 2012

PREPROCESS20

Page 21: Drupalcamp Gent 2012

21

»

Page 23: Drupalcamp Gent 2012

DEMO

hook_form_alter

23

Page 25: Drupalcamp Gent 2012

DEMO“I sometimes needa legal disclaimer”

25

Add a checkbox

There’s a catch :)

Page 26: Drupalcamp Gent 2012

theming26

Page 27: Drupalcamp Gent 2012

DEMO“I want mydefinition list”

Cannot just return html

use theming functions

theme(<hook>,...)

search in API for theme_<hook>

27

Page 28: Drupalcamp Gent 2012

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

Page 29: Drupalcamp Gent 2012

TAKE AWAY29

Page 31: Drupalcamp Gent 2012

31

Q & A

Page 32: Drupalcamp Gent 2012

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