SlideShare une entreprise Scribd logo
1  sur  47
Drupal Training




Module Building
Preparing for
Development
Preparing for
       Development
• Have a clear development workflow
Preparing for
        Development
• Have a clear development workflow
• Learn (and adopt) Drupal’s coding
  standards
Preparing for
         Development
• Have a clear development workflow
• Learn (and adopt) Drupal’s coding
  standards
• Take time to invest in your tools
Drupal’s Extenisbility
Drupal’s Extenisbility

• Drupal’s goal is “infinite extensibility” - this
  is what Drupal is generally optimizing for
Drupal’s Extenisbility

• Drupal’s goal is “infinite extensibility” - this
  is what Drupal is generally optimizing for
• The same APIs that define Drupal’s core
  functionality are available to you as a
  module developer
Drupal’s Extenisbility

• Drupal’s goal is “infinite extensibility” - this
  is what Drupal is generally optimizing for
• The same APIs that define Drupal’s core
  functionality are available to you as a
  module developer
• The hook system!
The Anatomy of a
    Module
The Anatomy of a
        Module

• my_module.info
The Anatomy of a
       Module

• my_module.info
• my_module.module
The Anatomy of a
        Module

• my_module.info
• my_module.module
• my_module.install
Database Abstraction
       Layer
Database Abstraction
        Layer
• Drupal provides a procedural wrapper to
  provide support for multiple types of
  databases (essentially MySQL and
  PostgreSQL)
Database Abstraction
        Layer
• Drupal provides a procedural wrapper to
  provide support for multiple types of
  databases (essentially MySQL and
  PostgreSQL)
• A thin (and somewhat outdated) wrapper
  around the underlying SQL
Database Abstraction
        Layer
• Drupal provides a procedural wrapper to
  provide support for multiple types of
  databases (essentially MySQL and
  PostgreSQL)
• A thin (and somewhat outdated) wrapper
  around the underlying SQL
• On it’s way out (Drupal 7 introduces a new
  db layer based on PDO)
db_query()
db_query()
• run a basic query in the active database
db_query()
• run a basic query in the active database
• any number of arguments are substituted
  into the query using printf() syntax.
db_fetch_result()
db_fetch_result()

• Return an individual result (not row) from
  the previous query
db_fetch_result()

• Return an individual result (not row) from
  the previous query
db_fetch_object
db_fetch_array
db_fetch_object
     db_fetch_array
• db_fetch_object() and db_fetch_array()
  fetch a row from the previous query as an
  object or array, respectively
db_fetch_object
     db_fetch_array
• db_fetch_object() and db_fetch_array()
  fetch a row from the previous query as an
  object or array, respectively
drupal_write_record()
drupal_write_record()
• Write or update a record in the database
  based upon the schema starting with an
  object or array
drupal_write_record()
• Write or update a record in the database
  based upon the schema starting with an
  object or array
The Hook System
The Hook System

• both core and contrib provide a set of
  “hooks” that your module can implement
  to add functionality to existing operations
The Hook System

• both core and contrib provide a set of
  “hooks” that your module can implement
  to add functionality to existing operations
• your module registers to be notified of a
  particular operation by implementing a
  hook
The Hook System
• sample hook:
• sample implementation:
• called by:
The Anatomy of the
php template engine
The Anatomy of the
  php template engine
• Files
The Anatomy of the
  php template engine
• Files
 • .info
The Anatomy of the
 php template engine
• Files
 • .info
 • .template
The Anatomy of the
 php template engine
• Files
 • .info
 • .template
 • .tpl.php
The Anatomy of the
  php template engine
• Files
 • .info
 • .template
 • .tpl.php
 • javascript/css/images
Anatomy cont.
Theme Registry
Theme Registry
• modules must implement hook_theme to
  declare their themable functions and
  templates
Theme Registry
• modules must implement hook_theme to
  declare their themable functions and
  templates
• these functions must be titled
  theme_function_name
Theme Registry
• modules must implement hook_theme to
  declare their themable functions and
  templates
• these functions must be titled
  theme_function_name
• theme(‘function_name’, $param) is then
  used to call the function
Implementing
hook_theme()
Providing a default
 theme function
Providing a default
    template

Contenu connexe

Tendances

Smau Milano 2016 - Fabio Alessandro Locati
Smau Milano 2016 - Fabio Alessandro LocatiSmau Milano 2016 - Fabio Alessandro Locati
Smau Milano 2016 - Fabio Alessandro LocatiSMAU
 
Building data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyBuilding data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyRoger Barnes
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Jan Helke
 
2017 JCP EC: Configuration JSR
2017 JCP EC: Configuration JSR2017 JCP EC: Configuration JSR
2017 JCP EC: Configuration JSRDavid Blevins
 
DSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDuraSpace
 
Deploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource ManagerDeploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource ManagerGlobalLogic Ukraine
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Andreas Jung
 
Solr Black Belt Pre-conference
Solr Black Belt Pre-conferenceSolr Black Belt Pre-conference
Solr Black Belt Pre-conferenceErik Hatcher
 
PostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databasePostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databaseReuven Lerner
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with SolrErik Hatcher
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr DevelopersErik Hatcher
 
Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Erik Hatcher
 
An Introduction to Accumulo
An Introduction to AccumuloAn Introduction to Accumulo
An Introduction to AccumuloDonald Miner
 
Solr 6 Feature Preview
Solr 6 Feature PreviewSolr 6 Feature Preview
Solr 6 Feature PreviewYonik Seeley
 
You know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msYou know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msJodok Batlogg
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsMicrosoft Tech Community
 
Pragmatic plone projects
Pragmatic plone projectsPragmatic plone projects
Pragmatic plone projectsAndreas Jung
 

Tendances (20)

Apache Kite
Apache KiteApache Kite
Apache Kite
 
Smau Milano 2016 - Fabio Alessandro Locati
Smau Milano 2016 - Fabio Alessandro LocatiSmau Milano 2016 - Fabio Alessandro Locati
Smau Milano 2016 - Fabio Alessandro Locati
 
Building data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemyBuilding data flows with Celery and SQLAlchemy
Building data flows with Celery and SQLAlchemy
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
 
2017 JCP EC: Configuration JSR
2017 JCP EC: Configuration JSR2017 JCP EC: Configuration JSR
2017 JCP EC: Configuration JSR
 
DSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & Configuration
 
Deploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource ManagerDeploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource Manager
 
Python mongo db-training-europython-2011
Python mongo db-training-europython-2011Python mongo db-training-europython-2011
Python mongo db-training-europython-2011
 
Solr Black Belt Pre-conference
Solr Black Belt Pre-conferenceSolr Black Belt Pre-conference
Solr Black Belt Pre-conference
 
PostgreSQL, your NoSQL database
PostgreSQL, your NoSQL databasePostgreSQL, your NoSQL database
PostgreSQL, your NoSQL database
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)Lucene's Latest (for Libraries)
Lucene's Latest (for Libraries)
 
An Introduction to Accumulo
An Introduction to AccumuloAn Introduction to Accumulo
An Introduction to Accumulo
 
Week3 adb
Week3 adbWeek3 adb
Week3 adb
 
Solr 6 Feature Preview
Solr 6 Feature PreviewSolr 6 Feature Preview
Solr 6 Feature Preview
 
Solr 4
Solr 4Solr 4
Solr 4
 
You know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msYou know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900ms
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analytics
 
Pragmatic plone projects
Pragmatic plone projectsPragmatic plone projects
Pragmatic plone projects
 

En vedette

System settings api
System settings apiSystem settings api
System settings apihtyson
 
Meet Drupal
Meet DrupalMeet Drupal
Meet Drupalhtyson
 
System settings
System settingsSystem settings
System settingshtyson
 
System settings api
System settings apiSystem settings api
System settings apihtyson
 
Solving The Deployment Problem
Solving The Deployment ProblemSolving The Deployment Problem
Solving The Deployment Problemhtyson
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

En vedette (6)

System settings api
System settings apiSystem settings api
System settings api
 
Meet Drupal
Meet DrupalMeet Drupal
Meet Drupal
 
System settings
System settingsSystem settings
System settings
 
System settings api
System settings apiSystem settings api
System settings api
 
Solving The Deployment Problem
Solving The Deployment ProblemSolving The Deployment Problem
Solving The Deployment Problem
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similaire à Modules Building Presentation

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
 
Advanced theming
Advanced themingAdvanced theming
Advanced themingtlattimore
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDavid Lanier
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Eugenio Minardi
 
Introduction to Python and Django
Introduction to Python and DjangoIntroduction to Python and Django
Introduction to Python and Djangosolutionstreet
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentDamjan Cvetan
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2Mizanur Rahaman Mizan
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an OverviewMatt Weaver
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesiMasters
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 

Similaire à Modules Building Presentation (20)

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
 
Automation using Puppet 3
Automation using Puppet 3 Automation using Puppet 3
Automation using Puppet 3
 
Advanced theming
Advanced themingAdvanced theming
Advanced theming
 
Advanced theming
Advanced themingAdvanced theming
Advanced theming
 
2012 03 08_dbi
2012 03 08_dbi2012 03 08_dbi
2012 03 08_dbi
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Java >= 9
Java >= 9Java >= 9
Java >= 9
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Django Pro ORM
Django Pro ORMDjango Pro ORM
Django Pro ORM
 
Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)Drupal theming - a practical approach (European Drupal Days 2015)
Drupal theming - a practical approach (European Drupal Days 2015)
 
Introduction to Python and Django
Introduction to Python and DjangoIntroduction to Python and Django
Introduction to Python and Django
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2
 
Codeinator
CodeinatorCodeinator
Codeinator
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 

Modules Building Presentation

Notes de l'éditeur