SlideShare a Scribd company logo
Developing for Drupal:
first steps, tips & tricks
    Drupal Camp Portugal 2012
             Luís Carneiro
    http://drupal.org/user/780690
          eltugis@gmail.com
Resources

• The example sandbox module
  – http://tinyurl.com/portocamp-module
Agenda

•   First steps
•   Some basics of the Drupal API
•   Presentation of coding examples
•   Questions and Discussion
Set your Developing Environment
•   Netbeans
•   Eclipse      Look for:
                 • Debugger integration
•   Aptana       • Function list view
•   Komodo IDE   • Jump to function
                 • Source control integration
•   Coda         • Ability to search across files
                 • Ability to configure syntax style
•   Vim            (follow coding standards)
•   …
Debugger is your friend
            See how the information flows
            Track bugs and understand code
Follow the coding standards
• drupal.org/coding-standards

• http://tinyurl.com/configuring-netbeans

• Use the coder module to validate your code
What is assumed

  You know the basic components of Drupal


Content
                Blocks       Taxonomies       Users
 Types


      Modules            Themes      Fields
Drupal Stack
              Drupal Theme

Contributed Modules    Custom Modules



          Drupal Core
Drupal API family
Module      Theme
                       Form API
System      System

                       Schema
Field API   DB Layer
                         API

 Menu       Search
                           …
System       API
Hook concept
• “Event listeners”
• Possibility to act in certain points of a page
  execution
  – To add our custom functionalities
  – To alter other’s functionalities


     • Drupal Moto: Don’t hack Core or
       others code!
Hooks

   hook_init       hook_menu

                                    Drupal Core has
hook_form_alter    hook_theme
                                    about 250 hooks!
                                    See the full list:
                                    http://tinyurl.com/drupal-hooks

  hook_mail       hook_field_info




 hook_schema            …
It all resumes to…


     module_invoke_all(‘hook_name’)
                  or
module_invoke(‘module_name’,’hook_name’)
What you need for a module
Files created in:
sites/all/modules/custom/yourmodule




       yourmodule.info            yourmodule.module




        yourmodule.install            README.txt
               (optional)             (good practice)
.info File

name = Your module name
description = Line description about module purpose
package = Group of modules it should belong
core = 7.x (or other version of Drupal)
files[] = yourmodule.module (and all other files which
code should run of every page)
Module Purpose
•   Create blocks
•   Create pages and forms
•   Create a new field type
•   Extend/customize Drupal core
•   Extend/customize Contributed modules
•   …
Form API
• drupal_get_form($form_id)
   – $form_id usually is <module_name>_<description>_form
   – Builds a form structure


• Many form elements
   – textfield, select, checkbox, radio, password…
   – The full reference list http://tinyurl.com/drupal-form-api

• validate and submit handlers
   – <form_id>_validate(&$form, &$form_state)
   – <form_id>_submit(&form, &$form_state)
Cache in Drupal
• Internal cache
  – Menu, Form, Path, Filter, Field…
  – Cache Page (specific for anonymous users)
     • The one you activate in “Performance” settings


• Custom cache
  – Two simple functions:
     • cache_set($cid, $data, $bin, $expire)
     • cache_get($cid, $bin)
Database Access

    Static                      Dynamic
   Queries                      queries
• Usually simple queries     • OOP query object
• Only Select queries may    • Database agnostic
  be static                  • Possibility to alter query
                               elements
db_query($sql_query)



             Full database API documentation
       http://drupal.org/developing/api/database
Theme System

Template File            or     Template Function


                Preprocessing
                  Functions

         • Set the variables for the templates
         • Define the logic
Theme Simple Example

                                               function theme_custom_output($variables) {
function yourmodule_theme() {                    …
  return array(                                  return $output;
    'custom_output' => array(                  }
      'variables' => array('node' => NULL),
    ),
  );                                           Function template_custom_output($variables) {
}                                                …
                                                 return $output;
                                               }

…
print theme('custom_output', array('node' =>   function yourtheme_custom_output($variables) {
                                                 …
$node));
                                                 return $output;
…                                              }



                                                    All valid theme definitions!
Theming tips
• Use devel themer module to find the theming
  elements on your page
• Clear theme registry cache when setting new
  templates

               Useful Resources:
               http://tinyurl.com/drupal-theme-implementations
               http://tinyurl.com/render-arrays
I see a lot of arrays!
$page = array(
  '#show_messages' => TRUE,
  '#theme' => 'page',                In many cases, the data used to
  '#type' => 'page',
  'content' => array(                build a page (and all parts of it) is
    'system_main' => array(...),     kept as structured arrays until the
    'another_block' => array(...),
    '#sorted' => TRUE,               rendering stage
  ),
  'sidebar_first' => array(
    ...                              Enormous flexibility in changing
  ),
  'footer' => array(                 the layout or content of a page
    ...                              and its components!
  ),
  ...
);
Use Drupal’s utility functions
• Function l(): Formats an internal or external URL link
  as an HTML anchor tag.
• Function t(): wrap text to be translated.
• Function drupal_set_message(): status message for
  user performed operations
• Function watchdog(): logs system messages to drupal
  log.
Simplify with Drush
• Command line tool to do common Drupal
  actions
    – Possibility to create your own drush
      commands…writing hooks!

Clear caches                               $ drush
Download/Enable modules                    $ drush help <command>
Synchronize dev and production databases
Check the log messages
…
Version Control Everything
• Code + Configurations (in database)
  – Code, easy to version control
  – Configurations… there comes Features +
    Strongarm module!
     • Database configurations exported to code
     • Tip: Keep your features small
Learning Resources
• Web
   – http://api.drupal.org
   – http://drupal.org/project/examples
   – http://drupal.org/developing/api
• Training
   – http://drupalize.me
   – http://buildamodule.com/
• Books
   – Drupal 7 Module Development
   – Pro Drupal 7 Development
   – Using Drupal 7

More Related Content

What's hot

Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Balázs Tatár
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
drubb
 
Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbai
vibrantuser
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
ramakesavan
 
Puppet DSL gotchas, and understandiing Roles & Profiles pattern
Puppet DSL gotchas, and understandiing Roles & Profiles patternPuppet DSL gotchas, and understandiing Roles & Profiles pattern
Puppet DSL gotchas, and understandiing Roles & Profiles patternAlex Simenduev
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
Alexandru Badiu
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Balázs Tatár
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
drubb
 
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
Mizanur Rahaman Mizan
 
Theme API
Theme APITheme API
Theme API
rolfvandekrol
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
Walter Ebert
 
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, PuppetPuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
Puppet
 
YAG - Yet another gallery (2012)
YAG - Yet another gallery (2012)YAG - Yet another gallery (2012)
YAG - Yet another gallery (2012)
Daniel Lienert
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
Nate Abele
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
Exove
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
ducquoc_vn
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 Workshop
Curtiss Grymala
 
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
 

What's hot (20)

Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
Php course-in-navimumbai
Php course-in-navimumbaiPhp course-in-navimumbai
Php course-in-navimumbai
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Puppet DSL gotchas, and understandiing Roles & Profiles pattern
Puppet DSL gotchas, and understandiing Roles & Profiles patternPuppet DSL gotchas, and understandiing Roles & Profiles pattern
Puppet DSL gotchas, and understandiing Roles & Profiles pattern
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
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
 
Theme API
Theme APITheme API
Theme API
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, PuppetPuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
PuppetConf 2017: Hiera 5: The Full Data Enchilada- Hendrik Lindberg, Puppet
 
YAG - Yet another gallery (2012)
YAG - Yet another gallery (2012)YAG - Yet another gallery (2012)
YAG - Yet another gallery (2012)
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
Ant_quick_guide
Ant_quick_guideAnt_quick_guide
Ant_quick_guide
 
WordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 WorkshopWordPress Themes 101 - PSUWeb13 Workshop
WordPress Themes 101 - PSUWeb13 Workshop
 
Any tutor
Any tutorAny tutor
Any tutor
 
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
 

Similar to Drupal Camp Porto - Developing with Drupal: First Steps

Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentationhtyson
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
DrupalMumbai
 
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
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
ipsitamishra
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
Siva Epari
 
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: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
Matt Weaver
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
Philip Norton
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
manugoel2003
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
Angela Byron
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2Confiz
 
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
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
Gábor Hojtsy
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
Opevel
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
Shabir Ahmad
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 module
tedbow
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
Gábor Hojtsy
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat
 

Similar to Drupal Camp Porto - Developing with Drupal: First Steps (20)

Modules Building Presentation
Modules Building PresentationModules Building Presentation
Modules Building Presentation
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
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
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010Drupal Module Development - OSI Days 2010
Drupal Module Development - OSI Days 2010
 
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
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2
 
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)
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
Advanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshareAdvanced moduledevelopment d6_slideshare
Advanced moduledevelopment d6_slideshare
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Your first d8 module
Your first d8 moduleYour first d8 module
Your first d8 module
 
Doing Drupal security right
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 

Recently uploaded

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
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
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
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
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
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
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
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
 
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
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 

Recently uploaded (20)

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
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...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
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
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
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
 
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
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 

Drupal Camp Porto - Developing with Drupal: First Steps

  • 1. Developing for Drupal: first steps, tips & tricks Drupal Camp Portugal 2012 Luís Carneiro http://drupal.org/user/780690 eltugis@gmail.com
  • 2. Resources • The example sandbox module – http://tinyurl.com/portocamp-module
  • 3. Agenda • First steps • Some basics of the Drupal API • Presentation of coding examples • Questions and Discussion
  • 4. Set your Developing Environment • Netbeans • Eclipse Look for: • Debugger integration • Aptana • Function list view • Komodo IDE • Jump to function • Source control integration • Coda • Ability to search across files • Ability to configure syntax style • Vim (follow coding standards) • …
  • 5. Debugger is your friend See how the information flows Track bugs and understand code
  • 6. Follow the coding standards • drupal.org/coding-standards • http://tinyurl.com/configuring-netbeans • Use the coder module to validate your code
  • 7. What is assumed You know the basic components of Drupal Content Blocks Taxonomies Users Types Modules Themes Fields
  • 8. Drupal Stack Drupal Theme Contributed Modules Custom Modules Drupal Core
  • 9. Drupal API family Module Theme Form API System System Schema Field API DB Layer API Menu Search … System API
  • 10. Hook concept • “Event listeners” • Possibility to act in certain points of a page execution – To add our custom functionalities – To alter other’s functionalities • Drupal Moto: Don’t hack Core or others code!
  • 11. Hooks hook_init hook_menu Drupal Core has hook_form_alter hook_theme about 250 hooks! See the full list: http://tinyurl.com/drupal-hooks hook_mail hook_field_info hook_schema …
  • 12. It all resumes to… module_invoke_all(‘hook_name’) or module_invoke(‘module_name’,’hook_name’)
  • 13. What you need for a module Files created in: sites/all/modules/custom/yourmodule yourmodule.info yourmodule.module yourmodule.install README.txt (optional) (good practice)
  • 14. .info File name = Your module name description = Line description about module purpose package = Group of modules it should belong core = 7.x (or other version of Drupal) files[] = yourmodule.module (and all other files which code should run of every page)
  • 15. Module Purpose • Create blocks • Create pages and forms • Create a new field type • Extend/customize Drupal core • Extend/customize Contributed modules • …
  • 16. Form API • drupal_get_form($form_id) – $form_id usually is <module_name>_<description>_form – Builds a form structure • Many form elements – textfield, select, checkbox, radio, password… – The full reference list http://tinyurl.com/drupal-form-api • validate and submit handlers – <form_id>_validate(&$form, &$form_state) – <form_id>_submit(&form, &$form_state)
  • 17. Cache in Drupal • Internal cache – Menu, Form, Path, Filter, Field… – Cache Page (specific for anonymous users) • The one you activate in “Performance” settings • Custom cache – Two simple functions: • cache_set($cid, $data, $bin, $expire) • cache_get($cid, $bin)
  • 18. Database Access Static Dynamic Queries queries • Usually simple queries • OOP query object • Only Select queries may • Database agnostic be static • Possibility to alter query elements db_query($sql_query) Full database API documentation http://drupal.org/developing/api/database
  • 19. Theme System Template File or Template Function Preprocessing Functions • Set the variables for the templates • Define the logic
  • 20. Theme Simple Example function theme_custom_output($variables) { function yourmodule_theme() { … return array( return $output; 'custom_output' => array( } 'variables' => array('node' => NULL), ), ); Function template_custom_output($variables) { } … return $output; } … print theme('custom_output', array('node' => function yourtheme_custom_output($variables) { … $node)); return $output; … } All valid theme definitions!
  • 21. Theming tips • Use devel themer module to find the theming elements on your page • Clear theme registry cache when setting new templates Useful Resources: http://tinyurl.com/drupal-theme-implementations http://tinyurl.com/render-arrays
  • 22. I see a lot of arrays! $page = array( '#show_messages' => TRUE, '#theme' => 'page', In many cases, the data used to '#type' => 'page', 'content' => array( build a page (and all parts of it) is 'system_main' => array(...), kept as structured arrays until the 'another_block' => array(...), '#sorted' => TRUE, rendering stage ), 'sidebar_first' => array( ... Enormous flexibility in changing ), 'footer' => array( the layout or content of a page ... and its components! ), ... );
  • 23. Use Drupal’s utility functions • Function l(): Formats an internal or external URL link as an HTML anchor tag. • Function t(): wrap text to be translated. • Function drupal_set_message(): status message for user performed operations • Function watchdog(): logs system messages to drupal log.
  • 24. Simplify with Drush • Command line tool to do common Drupal actions – Possibility to create your own drush commands…writing hooks! Clear caches $ drush Download/Enable modules $ drush help <command> Synchronize dev and production databases Check the log messages …
  • 25. Version Control Everything • Code + Configurations (in database) – Code, easy to version control – Configurations… there comes Features + Strongarm module! • Database configurations exported to code • Tip: Keep your features small
  • 26. Learning Resources • Web – http://api.drupal.org – http://drupal.org/project/examples – http://drupal.org/developing/api • Training – http://drupalize.me – http://buildamodule.com/ • Books – Drupal 7 Module Development – Pro Drupal 7 Development – Using Drupal 7

Editor's Notes

  1. Referirquemais a diantevãoserapresentadosexemplos da utilidade do Debugger.
  2. Apresentarmodule_invoke_all(&apos;init&apos;); no ficheiro “common.inc”
  3. Mostrar a form de administraçãocontruída.Mostrar a página da form apiAproveitarparafalar do “hook_menu” e “hook_permission”
  4. Aproveitarestetópicoparafalar no módulo “examples”.
  5. Apresentar a página de sandbox com uma query muito simples feita.Aproveitarparafalar do restante código.
  6. Exemplos: page, item_list, table, select list, etcEach theme can take control over most of Drupal&apos;s output, and has complete control over the CSS.Utilizar Debugger parafazer debug nafunção: “portocamp_theme_registry_alter” e mostrarosdiversoselementos de theme definidos.
  7. Mostrarexemplo do hook_themecriado.
  8. Show command line with drush and execute simple commands.