Session v1

Preview:

DESCRIPTION

 

Citation preview

BEGINNING MODULE DEVELOPMENT

Joe Crespo | Developer, Aten Design Group

Monday, July 1, 13

INTRODUCTIONS ARE IN ORDERDesktop publishing >> Graphic design >> Web design >> PHP developer >> Drupal

Joe Crespo | Developer, Aten Design Group

Monday, July 1, 13

PART 1“HELLO WORLD!”

Monday, July 1, 13

Drupal has its own set of vocabulary.1. “Nodes,” “entities,” and “modules” have

specific meanings in Drupal that may differ from what you think of as a

“node,” “entity,” or “module.”

Getting a handle on these concepts will elevate your Drupal development skills.

ESSENTIAL VOCABULARYTerms to Know:1. blocks

2. content types3. entities

4. fields5. hooks

6. nodes7. taxonomy

8. themes

Beginning Module Development | Getting Started

Monday, July 1, 13

hook_form_alter()Use your module to change an existing form.

drupal_add_css()Add your own CSS file to add styles or amend existing.

drupal_get_path()Returns a path within the Drupal site structure.

DRUPAL FUNCTIONS

Beginning Module Development | The Context Module

Monday, July 1, 13

1. Adding new functionality to Drupal means installing and activating existing modules, or creating new ones.

DRUPAL IS MODULAR

Beginning Module Development | Getting Started

Monday, July 1, 13

2. Modules communicate with one another and manipulate data through a series of hooks.

HOOKS

Beginning Module Development | Getting Started

Monday, July 1, 13

Hooks are functions automatically called during execution.

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

HOOKS 2: ELECTRIC BOOGALOO

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()

Monday, July 1, 13

1. Drupal 7 is not object-oriented. While Drupal does use objects, as its core, Drupal is procedural. 

DRUPAL IS NOT DOWN WITH O.O.P.

Beginning Module Development | Getting Started

Monday, July 1, 13

2. Drupal loves enormous multidimensional arrays.

YOU DOWN WITH OOP?

Beginning Module Development | Getting Started

Monday, July 1, 13

PART 2RULES OF THUMB

Monday, July 1, 13

DRUPAL DEVELOPMENT PRINCIPLES

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

Beginning Module Development | Rules of Thumb

Monday, July 1, 13

DRUPAL DEVELOPMENT FUNDAMENTALS1. Never add functionality to your

site by making changes to Drupal core.

2. Avoid hacking contrib modules.

Beginning Module Development | Rules of Thumb

Monday, July 1, 13

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

root directory |__ modules <<< this is where core modules live – DO NOT TOUCH! |__ sites |__ all    |__ modules         |__ contrib <<< this is where the modules you download live          |__ custom <<< this is where the modules you build live

ORGANIZING YOUR SITE

Beginning Module Development | Rules of Thumb

Monday, July 1, 13

• 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

Monday, July 1, 13

Clear the cache.

THE BEST DRUPAL TIP YOU’LL EVER HEAR

Beginning Module Development | Rules of Thumb

That is all.

Monday, July 1, 13

PART 3PUTTING THIS SESSION IN “CONTEXT”

Monday, July 1, 13

What Context does that’s pertinent to this session it that it allows site builders to add blocks of content to regions of the page if certain criteria are met.

For example:You want to advertise free shipping, but only want to show that message on your catalog index page at http://example.com/catalog. You would create a block advertising free shipping and then set the context to only show that block when the path is currently “catalog”

THE CONTEXT MODULE

Beginning Module Development | The Context Module

Monday, July 1, 13

DEMO

Monday, July 1, 13

CONCLUSIONWHAT HAVE WE LEARNED?

Monday, July 1, 13

What else can we do with context_ui_extras?

This module solves one problem with the UI, but maybe there are ways to improve it?

1. More efficient:

hook_ form_ FORM_ID_alter()2. Add a time condition to Context.

3. Make the Reactions draggable.

JUST THE TIP OF THE ICEBERG

Beginning Module Development | Now what?

Monday, July 1, 13

DRUPAL TOOLBOXGet 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 and a helpful support tool used

throughout the community.

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

Beginning Module Development | ToolboxMonday, July 1, 13

BEGINNING MODULE DEVELOPMENT

Joe Crespo | Developer, Aten Design Group

Monday, July 1, 13

Recommended