SlideShare una empresa de Scribd logo
1 de 26
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>

Más contenido relacionado

La actualidad más candente

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.1Gilles Guirand
 
Struts portlet-1
Struts portlet-1Struts portlet-1
Struts portlet-1AbhishekSRC
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
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 8Logan Farr
 
OOP Adventures with XOOPS
OOP Adventures with XOOPSOOP Adventures with XOOPS
OOP Adventures with XOOPSxoopsproject
 
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 8Anne 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 facetsAnyforSoft
 
crtical points for customizing Joomla templates
crtical points for customizing Joomla templatescrtical points for customizing Joomla templates
crtical points for customizing Joomla templatesamit 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 StepsLuís Carneiro
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & Moredrubb
 
20110606 e z_flow_gig_v1
20110606 e z_flow_gig_v120110606 e z_flow_gig_v1
20110606 e z_flow_gig_v1Gilles Guirand
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentDamjan Cvetan
 
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 Asseticxoopsproject
 
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 2014Peter Martin
 
Drupal8 corporate training in Hyderabad
Drupal8 corporate training in HyderabadDrupal8 corporate training in Hyderabad
Drupal8 corporate training in Hyderabadphp2ranjan
 

La actualidad más candente (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
 

Destacado

Presentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a defPresentatie mindful analysis nvv a def
Presentatie mindful analysis nvv a defMirjamnu
 
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
 
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
 
Internet freedom
Internet freedomInternet freedom
Internet freedomsibiyanto
 
Value creation in cure and care
Value creation in cure and careValue creation in cure and care
Value creation in cure and careDag Forsén
 
Omada 1
Omada 1Omada 1
Omada 1Ellh
 
Pedagogical Potential Of Social Media
Pedagogical  Potential Of  Social MediaPedagogical  Potential Of  Social Media
Pedagogical Potential Of Social Mediapqchienac
 
Zoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tipsZoekmachine Optimalisatie - een introductie en tips
Zoekmachine Optimalisatie - een introductie en tipsWieger 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 PROJECTSBjorn Freeman-Benson
 
Valen
ValenValen
Valenleydi
 
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 upjehill3
 
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 familjenDag Forsén
 
大葉資管系招生簡介
大葉資管系招生簡介大葉資管系招生簡介
大葉資管系招生簡介chenbbs
 

Destacado (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 a Intro to drupal module internals asheville

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 Drupal7marif4pk
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentRachit Gupta
 
Creating Drupal A Module
Creating Drupal A ModuleCreating Drupal A Module
Creating Drupal A Modulearcaneadam
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with DrupalRob Sawyer
 
Architecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal CampDipen 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 projectIztok 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 2009Emma 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 overviewDrupalMumbai
 
dylibencapsulation
dylibencapsulationdylibencapsulation
dylibencapsulationCole 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 MethodCeline 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 CatalogueAlexandre Israël
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
Drupal module development training delhi
Drupal module development training delhiDrupal module development training delhi
Drupal module development training delhiunitedwebsoft
 
Drupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDrupal 7 Features - Introduction - Basics
Drupal 7 Features - Introduction - BasicsDhinakaran Mani
 

Similar a 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
 

Más de 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 Tocgmonroe
 
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 Drupalcgmonroe
 
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 Sitescgmonroe
 
Becoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIBecoming "Facet"-nated with Search API
Becoming "Facet"-nated with Search APIcgmonroe
 
Using Content Delivery Networks with Drupal
Using Content Delivery Networks with DrupalUsing Content Delivery Networks with Drupal
Using Content Delivery Networks with Drupalcgmonroe
 
Solr facets and custom indices
Solr facets and custom indicesSolr facets and custom indices
Solr facets and custom indicescgmonroe
 
HTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEHTML Purifier, WYSIWYG, and TinyMCE
HTML Purifier, WYSIWYG, and TinyMCEcgmonroe
 
Using the Features API
Using the Features APIUsing the Features API
Using the Features APIcgmonroe
 
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 Drupalcgmonroe
 
Drupal Workflow Concepts
Drupal Workflow ConceptsDrupal Workflow Concepts
Drupal Workflow Conceptscgmonroe
 
TriDUG WebFM Presentation
TriDUG WebFM PresentationTriDUG WebFM Presentation
TriDUG WebFM Presentationcgmonroe
 

Más de 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
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 

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>