SlideShare a Scribd company logo
VIEWS for HACKERS an overview of Views programming v1.3 Karim Ratib (infojunkie@drupal) There's a module for that!
OBJECTIVES OF THIS TALK conceptual grasp of Views internal architecture ability to read Views and add-ons code ability to start coding Views add-ons
WHO AM I? Drupal user since 2005 infojunkie (uid 48424) Module author/maintainer since 2007 Views Bulk Operations Views Hacks Sheetnode Feeds Oauth Feeds Topics ... Drupal freelancer since 2008 There's a module for that! Vancouver, BC
OUTLINE CONTEXT  problem trivia definition   ARCHITECTURE overview components workflow file structure    EXAMPLES anatomy of Views add-ons
CONTEXT // problem coding node lists is boring coding node lists with filters is boring + 1 coding node lists with different themes is boring x 10 ... merlinofchaos chose to code all this for us!
CONTEXT // trivia   ,[object Object],  ,[object Object],   wc -l `find ./ -type f`     ,[object Object]
http://drupal.org/project/modules?filters=tid:89 ,[object Object],[object Object],      282K           Drupal      397K       CCK       269K   
CONTEXT // definition Views is a  SQL query generator and  renderer
ARCHITECTURE // overview // 1 SELECT n.title, u.name FROM {node} n INNER JOIN  {users} u ON n.uid = u.uid WHERE  n.status = 1 AND u.uid = arg(1) ORDER BY n.changed DESC hook_menu() => nodes/list theme('table', $results)
ARCHITECTURE // overview // 2 SELECT n.title, u.name  field FROM {node} n  base table = view type INNER JOIN  {users} u ON n.uid = u.uid  relationship WHERE  n.status = 1  filter AND u.uid = arg(1)  argument ORDER BY n.changed DESC  sort hook_menu() => nodes/list  display (page) theme('table', $results)  style (table)
ARCHITECTURE // overview // 3 same concepts are found on the Views UI view type, display, style, fields, filters, etc.
ARCHITECTURE // components // 1 containment relationships
ARCHITECTURE // components // 2 plugin type relationships
ARCHITECTURE // components // 3 handler type relationships
ARCHITECTURE // workflow BUILD init components, get arguments, generate SQL view::build() hook_views_pre_build(), post_build() hook_views_query_alter() EXECUTE execute SQL, store results  view::execute() hook_views_pre_execute(), post_execute() RENDER execute theme functions view::render() hook_views_pre_render(), post_render()
ARCHITECTURE // file structure  views /   Drupal façade      ./includes   core: view, query, base classes      ./handlers   SQL add-ons: fields, filters, arguments,                                    relationships, sort      ./plugins   non-SQL add-ons: display, style, row,                                   arg default, arg validator, access, cache, query (3.x), exposed form (3.x), pager (3.x)      ./theme   theme and preprocessor files        ./modules   data models + specialized handlers          ./node          ./user          ./taxonomy ...
EXAMPLES // views_block Exposing Drupal block data model to Views hook_views_api() inform Views that we exist (in mymodule.module) hook_views_data() define our data model (in mymodule.views.inc) hook_views_handlers() declare our field handlers (in mymodule.views.inc) hook_views_default_views() define our default views (in mymodule.views_default.inc) handlers classes define our field handlers (in individual files)
EXAMPLES // views_flipped_table Provide new style plugin to render view results hook_views_api() inform Views that we exist (in mymodule.module) hook_views_plugins() declare our style plugin (in mymodule.views.inc) theme template as declared above (in separate file) theme preprocessor corresponding to theme template (in mymodule.module)
EXAMPLES // views_autosubmit Auto-submit exposed form elements hook_views_api() not needed because we're bypassing Views! hook_form_views_exposed_form_alter() form altering code for Views exposed filters (in mymodule.module) Drupal.behaviors.views_autosubmit() bind to form input change to auto-submit the form (in mymodule.js)

More Related Content

Viewers also liked

Meditation
MeditationMeditation
Meditation
Robert Beshara
 
Anahata as Heart-centered Consciousness
Anahata as Heart-centered ConsciousnessAnahata as Heart-centered Consciousness
Anahata as Heart-centered Consciousness
Robert Beshara
 
Overview of Metabletics
Overview of MetableticsOverview of Metabletics
Overview of Metabletics
Robert Beshara
 
Self and identities
Self and identitiesSelf and identities
Self and identities
Robert Beshara
 
Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structures
Lorenzo Alberton
 
Checkdesk: Collaborative Verification in Action
Checkdesk: Collaborative Verification in ActionCheckdesk: Collaborative Verification in Action
Checkdesk: Collaborative Verification in Action
Karim Ratib
 

Viewers also liked (6)

Meditation
MeditationMeditation
Meditation
 
Anahata as Heart-centered Consciousness
Anahata as Heart-centered ConsciousnessAnahata as Heart-centered Consciousness
Anahata as Heart-centered Consciousness
 
Overview of Metabletics
Overview of MetableticsOverview of Metabletics
Overview of Metabletics
 
Self and identities
Self and identitiesSelf and identities
Self and identities
 
Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structures
 
Checkdesk: Collaborative Verification in Action
Checkdesk: Collaborative Verification in ActionCheckdesk: Collaborative Verification in Action
Checkdesk: Collaborative Verification in Action
 

Similar to Views for hackers v1.3

Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Rafael Coutinho
 
Drupal distributions - how to build them
Drupal distributions - how to build themDrupal distributions - how to build them
Drupal distributions - how to build them
Dick Olsson
 
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Carl Brown
 
B13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian DykeB13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian Dyke
Insight Technology, Inc.
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
Balint Erdi
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricks
John Tsevdos
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
ptalindstrom
 
Dn D Custom 1
Dn D Custom 1Dn D Custom 1
Dn D Custom 1
ptalindstrom
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
dn
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
Michael Rys
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
kenatmxm
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
Opensource gis development - part 5
Opensource gis development - part 5Opensource gis development - part 5
Opensource gis development - part 5
Andrea Antonello
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocol
Woodruff Solutions LLC
 
Making views - DrupalGov Canberra 2017
Making views - DrupalGov Canberra 2017Making views - DrupalGov Canberra 2017
Making views - DrupalGov Canberra 2017
Donna Benjamin
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
Nicolas Buduroi
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
ITNet
 
Best practices tekx
Best practices tekxBest practices tekx
Best practices tekx
Lorna Mitchell
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
Konstantin Komelin
 

Similar to Views for hackers v1.3 (20)

Drupal 8 Hooks
Drupal 8 HooksDrupal 8 Hooks
Drupal 8 Hooks
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Drupal distributions - how to build them
Drupal distributions - how to build themDrupal distributions - how to build them
Drupal distributions - how to build them
 
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
Advanced, Composable Collection Views, From CocoaCoders meetup Austin Feb 12,...
 
B13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian DykeB13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian Dyke
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricks
 
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
 
Patterns in Python
Patterns in PythonPatterns in Python
Patterns in Python
 
Killer Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQLKiller Scenarios with Data Lake in Azure with U-SQL
Killer Scenarios with Data Lake in Azure with U-SQL
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Opensource gis development - part 5
Opensource gis development - part 5Opensource gis development - part 5
Opensource gis development - part 5
 
Breaking down data silos with the open data protocol
Breaking down data silos with the open data protocolBreaking down data silos with the open data protocol
Breaking down data silos with the open data protocol
 
Making views - DrupalGov Canberra 2017
Making views - DrupalGov Canberra 2017Making views - DrupalGov Canberra 2017
Making views - DrupalGov Canberra 2017
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
Best practices tekx
Best practices tekxBest practices tekx
Best practices tekx
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
 

Recently uploaded

Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 

Recently uploaded (20)

Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 

Views for hackers v1.3

  • 1. VIEWS for HACKERS an overview of Views programming v1.3 Karim Ratib (infojunkie@drupal) There's a module for that!
  • 2. OBJECTIVES OF THIS TALK conceptual grasp of Views internal architecture ability to read Views and add-ons code ability to start coding Views add-ons
  • 3. WHO AM I? Drupal user since 2005 infojunkie (uid 48424) Module author/maintainer since 2007 Views Bulk Operations Views Hacks Sheetnode Feeds Oauth Feeds Topics ... Drupal freelancer since 2008 There's a module for that! Vancouver, BC
  • 4. OUTLINE CONTEXT problem trivia definition   ARCHITECTURE overview components workflow file structure   EXAMPLES anatomy of Views add-ons
  • 5. CONTEXT // problem coding node lists is boring coding node lists with filters is boring + 1 coding node lists with different themes is boring x 10 ... merlinofchaos chose to code all this for us!
  • 6.
  • 7.
  • 8. CONTEXT // definition Views is a SQL query generator and renderer
  • 9. ARCHITECTURE // overview // 1 SELECT n.title, u.name FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND u.uid = arg(1) ORDER BY n.changed DESC hook_menu() => nodes/list theme('table', $results)
  • 10. ARCHITECTURE // overview // 2 SELECT n.title, u.name field FROM {node} n base table = view type INNER JOIN {users} u ON n.uid = u.uid relationship WHERE n.status = 1 filter AND u.uid = arg(1) argument ORDER BY n.changed DESC sort hook_menu() => nodes/list display (page) theme('table', $results) style (table)
  • 11. ARCHITECTURE // overview // 3 same concepts are found on the Views UI view type, display, style, fields, filters, etc.
  • 12. ARCHITECTURE // components // 1 containment relationships
  • 13. ARCHITECTURE // components // 2 plugin type relationships
  • 14. ARCHITECTURE // components // 3 handler type relationships
  • 15. ARCHITECTURE // workflow BUILD init components, get arguments, generate SQL view::build() hook_views_pre_build(), post_build() hook_views_query_alter() EXECUTE execute SQL, store results view::execute() hook_views_pre_execute(), post_execute() RENDER execute theme functions view::render() hook_views_pre_render(), post_render()
  • 16. ARCHITECTURE // file structure views / Drupal façade     ./includes core: view, query, base classes     ./handlers SQL add-ons: fields, filters, arguments,                                    relationships, sort      ./plugins non-SQL add-ons: display, style, row,                                  arg default, arg validator, access, cache, query (3.x), exposed form (3.x), pager (3.x)      ./theme theme and preprocessor files      ./modules data models + specialized handlers          ./node         ./user         ./taxonomy ...
  • 17. EXAMPLES // views_block Exposing Drupal block data model to Views hook_views_api() inform Views that we exist (in mymodule.module) hook_views_data() define our data model (in mymodule.views.inc) hook_views_handlers() declare our field handlers (in mymodule.views.inc) hook_views_default_views() define our default views (in mymodule.views_default.inc) handlers classes define our field handlers (in individual files)
  • 18. EXAMPLES // views_flipped_table Provide new style plugin to render view results hook_views_api() inform Views that we exist (in mymodule.module) hook_views_plugins() declare our style plugin (in mymodule.views.inc) theme template as declared above (in separate file) theme preprocessor corresponding to theme template (in mymodule.module)
  • 19. EXAMPLES // views_autosubmit Auto-submit exposed form elements hook_views_api() not needed because we're bypassing Views! hook_form_views_exposed_form_alter() form altering code for Views exposed filters (in mymodule.module) Drupal.behaviors.views_autosubmit() bind to form input change to auto-submit the form (in mymodule.js)
  • 20. Karim Ratib (infojunkie@drupal) There's a module for that! http://there is a module for that.com Thank you!