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   First CVS checkin:  Fri Nov 25 20:33:09 2005 UTC by merlinofchaos   Lines of code:  95K+    wc -l `find ./ -type f`     3rd party sub-modules:  400+  
http://drupal.org/project/modules?filters=tid:89   Views       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

Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
Steven Carlson
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
maigasapphire
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
Priyanka Aash
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
FIDO Alliance
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
janagijoythi
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
Bhajan Mehta
 
Step-By-Step Process to Develop a Mobile App From Scratch
Step-By-Step Process to Develop a Mobile App From ScratchStep-By-Step Process to Develop a Mobile App From Scratch
Step-By-Step Process to Develop a Mobile App From Scratch
softsuave
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
Razin Mustafiz
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
siddu769252
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
Zilliz
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
BrainSell Technologies
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
Ivanti
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
bellared2
 
Types of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technologyTypes of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technology
ldtexsolbl
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
ZachWylie3
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
DianaGray10
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
Zilliz
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
Integrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecaseIntegrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecase
shyamraj55
 

Recently uploaded (20)

Vulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive OverviewVulnerability Management: A Comprehensive Overview
Vulnerability Management: A Comprehensive Overview
 
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
Girls Call Churchgate 9910780858 Provide Best And Top Girl Service And No1 in...
 
Redefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI CapabilitiesRedefining Cybersecurity with AI Capabilities
Redefining Cybersecurity with AI Capabilities
 
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
UX Webinar Series: Essentials for Adopting Passkeys as the Foundation of your...
 
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptxMAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
MAKE MONEY ONLINE Unlock Your Income Potential Today.pptx
 
Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17Mule Experience Hub and Release Channel with Java 17
Mule Experience Hub and Release Channel with Java 17
 
Step-By-Step Process to Develop a Mobile App From Scratch
Step-By-Step Process to Develop a Mobile App From ScratchStep-By-Step Process to Develop a Mobile App From Scratch
Step-By-Step Process to Develop a Mobile App From Scratch
 
The Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - CoatueThe Path to General-Purpose Robots - Coatue
The Path to General-Purpose Robots - Coatue
 
Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024Generative AI Reasoning Tech Talk - July 2024
Generative AI Reasoning Tech Talk - July 2024
 
Using LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and MilvusUsing LLM Agents with Llama 3, LangGraph and Milvus
Using LLM Agents with Llama 3, LangGraph and Milvus
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
 
Patch Tuesday de julio
Patch Tuesday de julioPatch Tuesday de julio
Patch Tuesday de julio
 
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
Russian Girls Call Navi Mumbai 🎈🔥9920725232 🔥💋🎈 Provide Best And Top Girl Ser...
 
Types of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technologyTypes of Weaving loom machine & it's technology
Types of Weaving loom machine & it's technology
 
Camunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptxCamunda Chapter NY Meetup July 2024.pptx
Camunda Chapter NY Meetup July 2024.pptx
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
 
It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...It's your unstructured data: How to get your GenAI app to production (and spe...
It's your unstructured data: How to get your GenAI app to production (and spe...
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
Integrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecaseIntegrating Kafka with MuleSoft 4 and usecase
Integrating Kafka with MuleSoft 4 and usecase
 

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. CONTEXT // trivia First CVS checkin: Fri Nov 25 20:33:09 2005 UTC by merlinofchaos   Lines of code: 95K+    wc -l `find ./ -type f`     3rd party sub-modules: 400+  
  • 7. http://drupal.org/project/modules?filters=tid:89   Views       282K          Drupal      397K       CCK       269K  
  • 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!