SlideShare a Scribd company logo
Intro To Drupal Module Internals
Greg Monroe
Longsight, Inc.
Triangle Drupal Users Group
How will this help?
Drupal is user contributed. This means that
documentation is often lacking. The people
writing modules generally say “Read the
code”
Knowing some basics about Drupal module
internals, even if you can't program, will help
you use even the worst documented module.
Skills and Tools
●
A very basic knowledge of PhP (e.g. can kinda
follow the basic logic but may not be able to
write it)
●
A decent (plain) text editor ( e.g. Notepad++,
Text Edit, Gedit )
●
Optionally, you could find a more PhP friendly
editor that displays a function list and allows for
searching thru multiple file/directories. (SciTE,
Geany, NotePad++ with plugins, Eclipse,
Aptana, Zend…)
How modules work
●
Core finds them via modules admin page
●
Stores info about them in System DB table
●
Enabling module sets flag in System DB table, creates
required DB tables, does initial setup and registration
duties.
●
Main code for enabled modules loaded at page “boot”
by core.
●
Module code gets called via “hooks” by core and other
modules
●
Module Magic happens
What are Hooks
●
Drupal is based on hooks
●
Modules use them to extend Drupal and to
extend themselves.
●
Hooks are associated with key actions, e.g.
saving a node.
●
When a hook action happens, core or a
module with hooks calls all modules that
have implemented the hook for that action.
Some Hook Fundamentals
●
Hooks are documented like hook_name,
e.g. hook_block_info
●
Modules implement hooks as functions with
names that replace “hook” with the module
name.
E.g, the foo module would implement
hook_menu as foo_menu
●
Core hooks usually are in *.module files
POP QUIZ
If you read something like:
The foo module uses hook_menu to
do that”
What name will this hook use?
Answer:
This translates into a function with
the form:
foo_menu
E.g.: function foo_menu() {
Extra credit for knowing it might be in the
foo.module file.
Additional Reading
A good place to start learning about core
hooks is
http://api.drupal.org/
Search for “Hooks” for the main page or
search for hook_<name> for a specific
hook.
Useful Module Splunking Hooks
●
Hook_help
●
Hook_menu
●
Hook_block_info
●
Hook_theme
●
Hook_permision
●
Hook_views_api
Note: You can find full documentation on hook by googling:
“Drupal api hook_<name>”
Module Directory
➢ Files for a module will be under a common
directory.
➢ The name of this directory is the module's
“basename”. E.g., Organic group is “og”
and Node Gallery uses node_gallery
Note: Module base directories can exist
under other modules, e.g. og_views is
found in og/modules/og_views…
Module Files
Required:
<basename>.info
<basename>.module
Recommended:
README(.txt)
LICENSE(.txt)
<basename>.install
Naming Conventions:
*.inc – Include files loaded
as needed
*.pages.inc – code needed
for general pages
*.admin.inc – code needed
for admin pages
*.tpl.php – Override-able
theme template files
*.api.php – Documents the
hooks this module has
An Example of Module files
●
The Organic Group Module
Finding a Module
➢ Finding a module that is creating some page or block
from the displayed page is hard… and beyond this talk…
➢ If you know the “Human name”, e.g. Organic Groups, you
can find the base name from the
drupal.org/project/<base name> URL.
➢ Knowing this, see if you can download it from Drupal.org.
Looking at a module outside your web server is MUCH
safer.
➢ But if you think your site’s code is custom or you can’t
find the Drupal Project….
Where’s Wald..err..
the Module
Modules can live many places… but by convention they
generally live under one of three directories:
<drupal root>/modules (Core only!)
<drupal root>/sites/all/modules (for all sites)
<drupal root>/sites/default/modules
Note: In multisite setups, the sites/default part above may be
your host name, e.g. sites/www.my.com
Next check to see if a basename directory exists… if not, use a
file search tool to look for <basename>.info under these
directories.
The .info file
The module.info file
contains:
●
Basic description of
the module.
●
Dependencies
●
Object class files used
by this module.
●
CSS and Script files
●
Configure URL
The .Module File
The <Basename>.module file contains the core code
for the module and generally all the hooks we’re
interested in.
Finding Hooks
With the .module file in an editor:
➢ If your editor show functions, just look for the
_<hook name> postfix, e.g. “_menu”
➢ Search for “hook_<hook name>”, e.g.
“hook_menu”
➢ Search for <basename>_<hook name>, e.g.
“og_menu”
➢ Look for _<hook name>, e.g. “_menu”
Hook_Help
Notes:
Supplies text for Drupal
Advanced help system
Case statements
– URL help applies to
Return statements
- Help text
Hook_Menu
Notes:
Defines URLs (as menu
items or just pages) for
“pages” the module
creates
$items[…] statements
– URL of page
- %xxx indicate argument
substitution
‘title’ array key
- Menu/Page title
‘page callback’ array key
- function to create page
‘access callback’ array key
- function that determines
access
Hook_Block_Info
Notes:
- Defines blocks this
module adds
- ‘info’ array key is name
shown in block admin
display
The “block_view” hook
defines how the block
contents are created
The “block_configure”
hook (not shown)
defines any block
specific configuration
options
Hook_Theme
Notes:
‘<basename>_xxx’ keys
- These define the theme
“hooks” for this module
‘arguments’ key
- Defines the values passed
to the theme hook
‘template’ key
- Indicates this theme hook
is a .tpl.php template file
‘path’ key
- The directory the tpl.php
file is located.
Code for non-template hooks
will be in theme_<name>
functions.
Hook_Permission
Notes:
Defines any module specific
permissions.
Note that many modules use
PhP constants to define
permissions. So, look at
these to get the names used
in the permission settings
screens.
Hook_views_api
If you find this hook, you know that this module supports
views and might be supplying blocks and pages thru
code embedded views it installs.
The path option will indicate where the views related .inc
files will “live”. If you look thru these you will generally
find the names of views this module creates.
Other places to look for views information is in the
Module .info file.
Some “Advanced” Hooks
hook_node_* A set of hooks to modify the node save,
display and load options.
hook_user_* A set of hooks to modify user actions,
e.g. load, save, display, login, etc.
hook_form_alter Allows any Drupal form to be modified
by another module
hook_schema Defines database tables used by this
Module. This will be in the .install file.
hook_cron Defines any cron “jobs” a module needs
hook_*_alter Functions of this form generally are
using a hook to alter something that
core or a module provides.
Questions / More Info
➢ The book Pro Drupal Development is a good
reference
➢ Drupal API site has lots of docs on hook
➢ DrupalContrib.org has lots of docs on non-
core hooks
➢ Of course Drupal.org and general search
will help you find lots of good stuff.
Especially if you search for hook_<name>

More Related Content

What's hot

20100622 e z_find_slides_gig_v2.1
20100622 e z_find_slides_gig_v2.120100622 e z_find_slides_gig_v2.1
20100622 e z_find_slides_gig_v2.1
Gilles Guirand
 
Struts portlet-1
Struts portlet-1Struts portlet-1
Struts portlet-1
AbhishekSRC
 
Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
drubb
 
Readme
ReadmeReadme
Readme
jsutcliffe
 
backend
backendbackend
backend
tutorialsruby
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
Logan Farr
 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPS
xoopsproject
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
Anne Tomasevich
 
Drupal 8. Search API. Facets. Customize / combine facets
Drupal 8. Search API. Facets. Customize / combine facetsDrupal 8. Search API. Facets. Customize / combine facets
Drupal 8. Search API. Facets. Customize / combine facets
AnyforSoft
 
crtical points for customizing Joomla templates
crtical points for customizing Joomla templatescrtical points for customizing Joomla templates
crtical points for customizing Joomla templates
amit das
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
Luís Carneiro
 
extending-php
extending-phpextending-php
extending-php
tutorialsruby
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & More
drubb
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1
Gilles Guirand
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
Damjan Cvetan
 
Quiz With Answers Drupal
Quiz With  Answers  DrupalQuiz With  Answers  Drupal
Quiz With Answers Drupal
Srinivasan Boominathan
 
XOOPS 2.6.0 Assets Management using Assetic
XOOPS 2.6.0 Assets Management using AsseticXOOPS 2.6.0 Assets Management using Assetic
XOOPS 2.6.0 Assets Management using Assetic
xoopsproject
 
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Peter Martin
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
php2ranjan
 

What's hot (20)

20100622 e z_find_slides_gig_v2.1
20100622 e z_find_slides_gig_v2.120100622 e z_find_slides_gig_v2.1
20100622 e z_find_slides_gig_v2.1
 
Struts portlet-1
Struts portlet-1Struts portlet-1
Struts portlet-1
 
Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Readme
ReadmeReadme
Readme
 
backend
backendbackend
backend
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPS
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
 
Drupal 8. Search API. Facets. Customize / combine facets
Drupal 8. Search API. Facets. Customize / combine facetsDrupal 8. Search API. Facets. Customize / combine facets
Drupal 8. Search API. Facets. Customize / combine facets
 
crtical points for customizing Joomla templates
crtical points for customizing Joomla templatescrtical points for customizing Joomla templates
crtical points for customizing Joomla templates
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
extending-php
extending-phpextending-php
extending-php
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & More
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Quiz With Answers Drupal
Quiz With  Answers  DrupalQuiz With  Answers  Drupal
Quiz With Answers Drupal
 
XOOPS 2.6.0 Assets Management using Assetic
XOOPS 2.6.0 Assets Management using AsseticXOOPS 2.6.0 Assets Management using Assetic
XOOPS 2.6.0 Assets Management using Assetic
 
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabad
 

Viewers also liked

Presentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a defPresentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a def
Mirjamnu
 
Das redes as_ruas_aline_carvalho
Das redes as_ruas_aline_carvalhoDas redes as_ruas_aline_carvalho
Das redes as_ruas_aline_carvalhoAline Carvalho
 
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
Cintas Foundation
 
Olma Presentation
Olma PresentationOlma Presentation
Olma Presentation
Brazil Means Business
 
Blogger μικρός οδηγός
Blogger  μικρός οδηγόςBlogger  μικρός οδηγός
Blogger μικρός οδηγόςEllh
 
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
jehill3
 
Nz powerpoint
Nz powerpointNz powerpoint
Nz powerpoint
Tony Nicholas
 
Internet freedom
Internet freedomInternet freedom
Internet freedom
sibiyanto
 
Value creation in cure and care
Value creation in cure and careValue creation in cure and care
Value creation in cure and care
Dag Forsén
 
Dia de Canarias
Dia de CanariasDia de Canarias
Omada 1
Omada 1Omada 1
Omada 1
Ellh
 
Vertrouw je mij?
Vertrouw je mij?Vertrouw je mij?
Vertrouw je mij?
Hans Keesenberg
 
Pedagogical Potential Of Social Media
Pedagogical  Potential Of  Social MediaPedagogical  Potential Of  Social Media
Pedagogical Potential Of Social Media
pqchienac
 
Zoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tipsZoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tips
Wieger Waardenburg
 
Heart presentation
Heart presentation Heart presentation
Heart presentation
jaccalder
 
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTSAIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
Bjorn Freeman-Benson
 
Valen
ValenValen
Valen
leydi
 
Community case management: IRC’s experience and considerations for scale up
Community case management: IRC’s experience and considerations for scale upCommunity case management: IRC’s experience and considerations for scale up
Community case management: IRC’s experience and considerations for scale up
jehill3
 
Digital måbarteknik för hela familjen
Digital måbarteknik för hela familjenDigital måbarteknik för hela familjen
Digital måbarteknik för hela familjen
Dag Forsén
 
大葉資管系招生簡介
大葉資管系招生簡介大葉資管系招生簡介
大葉資管系招生簡介chenbbs
 

Viewers also liked (20)

Presentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a defPresentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a def
 
Das redes as_ruas_aline_carvalho
Das redes as_ruas_aline_carvalhoDas redes as_ruas_aline_carvalho
Das redes as_ruas_aline_carvalho
 
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
CINTAS Foundation and MDC Museum of Art + Design Announce 2015-16 Fellowship ...
 
Olma Presentation
Olma PresentationOlma Presentation
Olma Presentation
 
Blogger μικρός οδηγός
Blogger  μικρός οδηγόςBlogger  μικρός οδηγός
Blogger μικρός οδηγός
 
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
Maternal Anemia within Child Survival Grants Program:  Lessons Learned and a ...
 
Nz powerpoint
Nz powerpointNz powerpoint
Nz powerpoint
 
Internet freedom
Internet freedomInternet freedom
Internet freedom
 
Value creation in cure and care
Value creation in cure and careValue creation in cure and care
Value creation in cure and care
 
Dia de Canarias
Dia de CanariasDia de Canarias
Dia de Canarias
 
Omada 1
Omada 1Omada 1
Omada 1
 
Vertrouw je mij?
Vertrouw je mij?Vertrouw je mij?
Vertrouw je mij?
 
Pedagogical Potential Of Social Media
Pedagogical  Potential Of  Social MediaPedagogical  Potential Of  Social Media
Pedagogical Potential Of Social Media
 
Zoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tipsZoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tips
 
Heart presentation
Heart presentation Heart presentation
Heart presentation
 
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTSAIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
AIRPLANES, SPACESHIPS, AND MISSILES: ENGINEERING LESSONS FROM FAMOUS PROJECTS
 
Valen
ValenValen
Valen
 
Community case management: IRC’s experience and considerations for scale up
Community case management: IRC’s experience and considerations for scale upCommunity case management: IRC’s experience and considerations for scale up
Community case management: IRC’s experience and considerations for scale up
 
Digital måbarteknik för hela familjen
Digital måbarteknik för hela familjenDigital måbarteknik för hela familjen
Digital måbarteknik för hela familjen
 
大葉資管系招生簡介
大葉資管系招生簡介大葉資管系招生簡介
大葉資管系招生簡介
 

Similar to Intro to drupal module internals asheville

Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
Vibrant Technologies & Computers
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7
marif4pk
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
Rachit Gupta
 
Drupal
DrupalDrupal
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Module
arcaneadam
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
Rob Sawyer
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
Dipen Chaudhary
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
Iztok Smolic
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
Emma Jane Hogbin Westby
 
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
DrupalMumbai
 
dylibencapsulation
dylibencapsulationdylibencapsulation
dylibencapsulation
Cole Herzog
 
How to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold MethodHow to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold Method
Celine George
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
sroo galal
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices Catalogue
Alexandre Israël
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
Gerald Villorente
 
Drupal module development training delhi
Drupal module development training delhiDrupal module development training delhi
Drupal module development training delhi
unitedwebsoft
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
ptalindstrom
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
ptalindstrom
 
Drupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDrupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - Basics
Dhinakaran Mani
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
Emma Jane Hogbin Westby
 

Similar to Intro to drupal module internals asheville (20)

Drupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating ModulesDrupal - Introduction to Drupal Creating Modules
Drupal - Introduction to Drupal Creating Modules
 
Custom module and theme development in Drupal7
Custom module and theme development in Drupal7Custom module and theme development in Drupal7
Custom module and theme development in Drupal7
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Drupal
DrupalDrupal
Drupal
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Module
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
 
Top 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal projectTop 20 mistakes you will make on your 1st Drupal project
Top 20 mistakes you will make on your 1st Drupal project
 
Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009Learning PHP for Drupal Theming, DC Chicago 2009
Learning PHP for Drupal Theming, DC Chicago 2009
 
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
13th Sep - Drupal Global Training Day by TCS - Drupal core advanced overview
 
dylibencapsulation
dylibencapsulationdylibencapsulation
dylibencapsulation
 
How to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold MethodHow to Build a Module in Odoo 15 Scaffold Method
How to Build a Module in Odoo 15 Scaffold Method
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
The Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices CatalogueThe Drupal 7 Worst Practices Catalogue
The Drupal 7 Worst Practices Catalogue
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Drupal module development training delhi
Drupal module development training delhiDrupal module development training delhi
Drupal module development training delhi
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
 
Drupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDrupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - Basics
 
Drupal Front End PHP
Drupal Front End PHPDrupal Front End PHP
Drupal Front End PHP
 

More from cgmonroe

Structured SEO Data Overview and How To
Structured SEO Data Overview and How ToStructured SEO Data Overview and How To
Structured SEO Data Overview and How To
cgmonroe
 
Structured SEO Data: An overview and how to for Drupal
Structured SEO Data:  An overview and how to for DrupalStructured SEO Data:  An overview and how to for Drupal
Structured SEO Data: An overview and how to for Drupal
cgmonroe
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
cgmonroe
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sites
cgmonroe
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search API
cgmonroe
 
Using Content Delivery Networks with Drupal
Using Content Delivery Networks with DrupalUsing Content Delivery Networks with Drupal
Using Content Delivery Networks with Drupal
cgmonroe
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indices
cgmonroe
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCE
cgmonroe
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
cgmonroe
 
The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.
cgmonroe
 
Intro to CSS Selectors in Drupal
Intro to CSS Selectors in DrupalIntro to CSS Selectors in Drupal
Intro to CSS Selectors in Drupal
cgmonroe
 
Drupal Workflow Concepts
Drupal Workflow ConceptsDrupal Workflow Concepts
Drupal Workflow Concepts
cgmonroe
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentation
cgmonroe
 

More from cgmonroe (13)

Structured SEO Data Overview and How To
Structured SEO Data Overview and How ToStructured SEO Data Overview and How To
Structured SEO Data Overview and How To
 
Structured SEO Data: An overview and how to for Drupal
Structured SEO Data:  An overview and how to for DrupalStructured SEO Data:  An overview and how to for Drupal
Structured SEO Data: An overview and how to for Drupal
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
 
Tips on Securing Drupal Sites
Tips on Securing Drupal SitesTips on Securing Drupal Sites
Tips on Securing Drupal Sites
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search API
 
Using Content Delivery Networks with Drupal
Using Content Delivery Networks with DrupalUsing Content Delivery Networks with Drupal
Using Content Delivery Networks with Drupal
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indices
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCE
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features API
 
The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.The Drupal Strongarm Module - Tips and Tricks.
The Drupal Strongarm Module - Tips and Tricks.
 
Intro to CSS Selectors in Drupal
Intro to CSS Selectors in DrupalIntro to CSS Selectors in Drupal
Intro to CSS Selectors in Drupal
 
Drupal Workflow Concepts
Drupal Workflow ConceptsDrupal Workflow Concepts
Drupal Workflow Concepts
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentation
 

Recently uploaded

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 

Recently uploaded (20)

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 

Intro to drupal module internals asheville

  • 1. Intro To Drupal Module Internals Greg Monroe Longsight, Inc. Triangle Drupal Users Group
  • 2. How will this help? Drupal is user contributed. This means that documentation is often lacking. The people writing modules generally say “Read the code” Knowing some basics about Drupal module internals, even if you can't program, will help you use even the worst documented module.
  • 3. Skills and Tools ● A very basic knowledge of PhP (e.g. can kinda follow the basic logic but may not be able to write it) ● A decent (plain) text editor ( e.g. Notepad++, Text Edit, Gedit ) ● Optionally, you could find a more PhP friendly editor that displays a function list and allows for searching thru multiple file/directories. (SciTE, Geany, NotePad++ with plugins, Eclipse, Aptana, Zend…)
  • 4. How modules work ● Core finds them via modules admin page ● Stores info about them in System DB table ● Enabling module sets flag in System DB table, creates required DB tables, does initial setup and registration duties. ● Main code for enabled modules loaded at page “boot” by core. ● Module code gets called via “hooks” by core and other modules ● Module Magic happens
  • 5. What are Hooks ● Drupal is based on hooks ● Modules use them to extend Drupal and to extend themselves. ● Hooks are associated with key actions, e.g. saving a node. ● When a hook action happens, core or a module with hooks calls all modules that have implemented the hook for that action.
  • 6. Some Hook Fundamentals ● Hooks are documented like hook_name, e.g. hook_block_info ● Modules implement hooks as functions with names that replace “hook” with the module name. E.g, the foo module would implement hook_menu as foo_menu ● Core hooks usually are in *.module files
  • 7. POP QUIZ If you read something like: The foo module uses hook_menu to do that” What name will this hook use?
  • 8. Answer: This translates into a function with the form: foo_menu E.g.: function foo_menu() { Extra credit for knowing it might be in the foo.module file.
  • 9. Additional Reading A good place to start learning about core hooks is http://api.drupal.org/ Search for “Hooks” for the main page or search for hook_<name> for a specific hook.
  • 10. Useful Module Splunking Hooks ● Hook_help ● Hook_menu ● Hook_block_info ● Hook_theme ● Hook_permision ● Hook_views_api Note: You can find full documentation on hook by googling: “Drupal api hook_<name>”
  • 11. Module Directory ➢ Files for a module will be under a common directory. ➢ The name of this directory is the module's “basename”. E.g., Organic group is “og” and Node Gallery uses node_gallery Note: Module base directories can exist under other modules, e.g. og_views is found in og/modules/og_views…
  • 12. Module Files Required: <basename>.info <basename>.module Recommended: README(.txt) LICENSE(.txt) <basename>.install Naming Conventions: *.inc – Include files loaded as needed *.pages.inc – code needed for general pages *.admin.inc – code needed for admin pages *.tpl.php – Override-able theme template files *.api.php – Documents the hooks this module has
  • 13. An Example of Module files ● The Organic Group Module
  • 14. Finding a Module ➢ Finding a module that is creating some page or block from the displayed page is hard… and beyond this talk… ➢ If you know the “Human name”, e.g. Organic Groups, you can find the base name from the drupal.org/project/<base name> URL. ➢ Knowing this, see if you can download it from Drupal.org. Looking at a module outside your web server is MUCH safer. ➢ But if you think your site’s code is custom or you can’t find the Drupal Project….
  • 15. Where’s Wald..err.. the Module Modules can live many places… but by convention they generally live under one of three directories: <drupal root>/modules (Core only!) <drupal root>/sites/all/modules (for all sites) <drupal root>/sites/default/modules Note: In multisite setups, the sites/default part above may be your host name, e.g. sites/www.my.com Next check to see if a basename directory exists… if not, use a file search tool to look for <basename>.info under these directories.
  • 16. The .info file The module.info file contains: ● Basic description of the module. ● Dependencies ● Object class files used by this module. ● CSS and Script files ● Configure URL
  • 17. The .Module File The <Basename>.module file contains the core code for the module and generally all the hooks we’re interested in.
  • 18. Finding Hooks With the .module file in an editor: ➢ If your editor show functions, just look for the _<hook name> postfix, e.g. “_menu” ➢ Search for “hook_<hook name>”, e.g. “hook_menu” ➢ Search for <basename>_<hook name>, e.g. “og_menu” ➢ Look for _<hook name>, e.g. “_menu”
  • 19. Hook_Help Notes: Supplies text for Drupal Advanced help system Case statements – URL help applies to Return statements - Help text
  • 20. Hook_Menu Notes: Defines URLs (as menu items or just pages) for “pages” the module creates $items[…] statements – URL of page - %xxx indicate argument substitution ‘title’ array key - Menu/Page title ‘page callback’ array key - function to create page ‘access callback’ array key - function that determines access
  • 21. Hook_Block_Info Notes: - Defines blocks this module adds - ‘info’ array key is name shown in block admin display The “block_view” hook defines how the block contents are created The “block_configure” hook (not shown) defines any block specific configuration options
  • 22. Hook_Theme Notes: ‘<basename>_xxx’ keys - These define the theme “hooks” for this module ‘arguments’ key - Defines the values passed to the theme hook ‘template’ key - Indicates this theme hook is a .tpl.php template file ‘path’ key - The directory the tpl.php file is located. Code for non-template hooks will be in theme_<name> functions.
  • 23. Hook_Permission Notes: Defines any module specific permissions. Note that many modules use PhP constants to define permissions. So, look at these to get the names used in the permission settings screens.
  • 24. Hook_views_api If you find this hook, you know that this module supports views and might be supplying blocks and pages thru code embedded views it installs. The path option will indicate where the views related .inc files will “live”. If you look thru these you will generally find the names of views this module creates. Other places to look for views information is in the Module .info file.
  • 25. Some “Advanced” Hooks hook_node_* A set of hooks to modify the node save, display and load options. hook_user_* A set of hooks to modify user actions, e.g. load, save, display, login, etc. hook_form_alter Allows any Drupal form to be modified by another module hook_schema Defines database tables used by this Module. This will be in the .install file. hook_cron Defines any cron “jobs” a module needs hook_*_alter Functions of this form generally are using a hook to alter something that core or a module provides.
  • 26. Questions / More Info ➢ The book Pro Drupal Development is a good reference ➢ Drupal API site has lots of docs on hook ➢ DrupalContrib.org has lots of docs on non- core hooks ➢ Of course Drupal.org and general search will help you find lots of good stuff. Especially if you search for hook_<name>