drupal 7 development: beginning module development

16
BEGINNING MODULE DEVELOPMENT Joe Crespo | Developer, Aten Design Group

Upload: joe-crespo

Post on 17-Jan-2017

151 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Drupal 7 Development: Beginning Module Development

BEGINNING MODULE DEVELOPMENT

Joe Crespo | Developer, Aten Design Group

Page 2: Drupal 7 Development: Beginning Module Development

YOUR NOT-SO-HUMBLE PRESENTERDesktop publishing >> Graphic design >> Web design >> PHP developer >> Drupal

Joe Crespo | Developer, Aten Design Group

Page 3: Drupal 7 Development: Beginning Module Development

“Hello World”

PART 1

Page 4: Drupal 7 Development: Beginning Module Development

DRUPAL TOOLBOX

Get to know these things: (if you don’t already)

1. Git: The version control software of choice for Drupal.

2. drush: A command line tool used for Drupal development.

3. devel: A really useful Drupal development module.

4. IRC: Internet Relay Chat (IM). #drupal-colorado

5. api.drupal.org is your new best friend.

Beginning Module Development | Intro

Page 5: Drupal 7 Development: Beginning Module Development

DRUPAL TOOLBOX

Super-common Drupal functions we’ll look at today:

1. arg() - http://bit.ly/function_arg

2. form_set_error() - http://bit.ly/form_set_error

3. check_plain() - http://bit.ly/check_plain

4. t() - http://bit.ly/function_t

Super-common functions we probably won’t get to:

1. variable_get() - http://bit.ly/variable_get

2. variable_set() - http://bit.ly/variable_set

Beginning Module Development | Intro

Page 6: Drupal 7 Development: Beginning Module Development

DRUPAL TOOLBOX

The ‘devel’ module… essential! Essential!! ESSENTIAL!!!

Provides the world’s most useful function:

• dpm() - http://bit.ly/function_dpm

Gives you a great place to test your scripts:

• http://yoursite.domain/devel/php

Beginning Module Development | Intro

Page 7: Drupal 7 Development: Beginning Module Development

Hooks are functions automatically called during execution.

Your module makes changes to content or functionality by invoking these hooks.

Beginning Module Development | Getting Started

For example: Your Module Name: my_first_moduleDrupal Hook:  hook_form_alter()Module invokes Hook with my_first_module_form_alter()

DRUPAL TOOLBOX: HOOKS

Page 8: Drupal 7 Development: Beginning Module Development

DRUPAL TOOLBOX: HOOKS

Hooks you'll use constantly!

1. hook_init() - http://bit.ly/hook_init (sparingly!)

2. hook_form_alter() - http://bit.ly/form_alter

Other super-common hooks we won’t get to today:

1. hook_menu() - http://bit.ly/hook_menu

2. hook_node_presave() - http://bit.ly/hook_node_presave

3. hook_form_FORM_ID_alter() - http://bit.ly/hook_form_FORM_ID_alter

4. hook_form_BASE_FORM_ID_alter()- http://bit.ly/hook_form_BASE_FORM_ID_alter

Beginning Module Development | Intro

Page 9: Drupal 7 Development: Beginning Module Development

PART 2Rules of Thumb

Page 10: Drupal 7 Development: Beginning Module Development

DRUPAL DEVELOPMENT PRINCIPLES

“Every time you hack core, God kills a kitten”

Beginning Module Development | Rules of Thumb

DRUPAL PRESENTATION

OBLIGATORY KITTEN PHOTO

Page 11: Drupal 7 Development: Beginning Module Development

Separate Drupal core modules, contrib modules, and your custom modules.

ORGANIZING YOUR SITE

Beginning Module Development | Rules of Thumb

Page 12: Drupal 7 Development: Beginning Module Development

• Always keep in mind that the

module you are contemplating might

already exist.

• Search Drupal.org to see if the

module has already been built.

• If you don’t find an obvious answer,

ask on IRC.

BEFORE YOU START DEVELOPING A MODULE

Beginning Module Development | Rules of Thumb

Page 13: Drupal 7 Development: Beginning Module Development

Clear the cache

Clear the Clear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cache

Clear the cache

Clear the Clear the cache

Clear the cache

Clear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cache

Clear the

Clear the cacheClear the cacheClear the cacheClear the cacheClear the cache

Clear the cacheClear the cache

Clear the cacheClear the cache

Clear the cache

Clear the cacheClear the

Clear the cache

Clear the cache

Clear the cache

Clear the cacheClear the cache

Clear the cacheClear the cacheClear the cacheClear the cache

Clear the cacheClear the cache

Beginning Module Development | Rules of Thumb

Page 14: Drupal 7 Development: Beginning Module Development

PART 3The long, long live demo(operating without a net)

Page 15: Drupal 7 Development: Beginning Module Development

CONCLUSION

Page 16: Drupal 7 Development: Beginning Module Development

BEGINNING MODULE DEVELOPMENT

Joe Crespo | Developer, Aten Design Group