SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Fields, Entities and Lists,
Oh My!
October 24, 2015
Saturday, October 24, 15
Good morning everyone, and welcome to Fields, Entities and Lists, Oh My!
Senior Developer
Email: jturton@phase2technology.com
Joshua Turton
Twitter: @sjinteractive and @phase2
Drupal.org: srjosh
Saturday, October 24, 15
[ Introduction of me ]
Today we'll be talking about some important concepts and tools that are key to developing in Drupal 7 - Fields, Entities, and Lists. We’ll be talking about
them mostly from a code perspective, so I’m going to make the assumption that you know at least enough to make a basic module and get Drupal to
recognize and enable it.
The things I’m covering today are all items I use practically every week, and a good working knowledge of them will make your life as a developer much
more productive.
Entities and Fields
Saturday, October 24, 15
We’ll start with two of the most powerful and widely used tools in Drupal - entities and fields.
Introduced in a limited fashion in Drupal 5 & 6 with "Nodes", they became standardized in Drupal 7, and they are everywhere in Drupal 8. Knowledge of
what they can do and how to use them is critical.
At their core, entities are units of information. They are PHP objects, defined by classes, which allow for the storage and manipulation of various types of
data.
Core Entity Types
• Nodes
• Comments
• Taxonomy Terms
• User Profiles
Saturday, October 24, 15
These are the entity types that ship with Drupal core. Contributed modules greatly expand this list, and you can create your own entities as well!
Drupal also allows you to define different "types" of those entities, to use for different purposes.
[ Discuss:

 * Show Content Types

 * Talk about usefulness via Fields

 * Show Fields admin for node

 * Show Fields admin for taxonomy type, talk about standardization of interface
]
Core Field Types (and their modules)
• Textfield (text)
• Textarea (text)
• Textarea with Summary (text)
• File (file)
• Image (image)
• Radio Buttons (options)
• Checkboxes (options)
• Single Select (options)
• Multi-select (options)
• Taxonomy Term (taxonomy)
• Decimal (number)
• Float (number)
• Integer (number)
Saturday, October 24, 15
These are the field types that ship with Drupal core. Contributed modules greatly expand this list, and you can create your own as well (though there are so
many available that there’s rarely a case for that, honestly).
Useful Contrib Fields (and their modules)
• Date (date)
• Date Popup (date)
• Media (media)
• Media YouTube (media_youtube)
• Entity Reference (entityreference)
Saturday, October 24, 15
These are just a few of the available field types that come from contributed modules, but they are some of my favorites. Indeed, I’d argue that at least
some of these are pretty much essential.
Aw, CRUD!
• Create
• Read
• Update
• Delete
Saturday, October 24, 15
Drupal allows you to store and access information in the database directly - there is lots of functionality devoted to database interactions. So, how are
entities different? Why would we use them instead of just storing information in the DB?
One of the most powerful parts of Drupal has to do with what we call CRUD operations: Create, Read, Update, Delete. All of these entity types
automatically define their own HTML forms to do those operations. You don't have to write a whole set of forms, form handling code, validations,
database operations, and confirmation messages for each of them. It all happens automatically as soon as you turn on their module(s) and configure the
types and fields.
[ Discuss:

 * Break out to show Demo Site, edit node
]
Using Entities and
Fields in Code
Saturday, October 24, 15
So, most of this is pretty basic stuff that you’re probably already using. So why am I showing it?
Because all of this stuff exists in the code, too. Entities are standardized in their User Experience, but also on the code side too.
entity_load
Saturday, October 24, 15
Want to load an entity in code? Use [entityname]_load, and give it the id you want to load. All entity types have a load function.
Now, what do I mean by “load” an entity?
Loading an entity means, querying the database for one or more blocks of content, by id number. Drupal goes and gets the all the data from all the fields
and tables related to that block of content, and assembles them as a PHP object, so that you can do whatever you need to do. This is the “R” - Read - in
CRUD.
node_load
Saturday, October 24, 15
And all entity load functions implement the core function “entity_load”.
Sometimes there’s a layer between them, but ultimately all entities work this way.
[entity]_save
Saturday, October 24, 15
Saving an entity - either a new one or one that already exists, is much the same.
A new one would be the “C” in CRUD, for “Create”, while an existing one would be the “U”, for “Update”.
Each entity type has an [entityname]_save function, though it’s worth noting that, at least in Drupal 7, they actually do not call a centralized entity_save
function.
However, they all work more or less the same way; you load or create a PHP object with the right values, then call the function and pass it that object. The
difference between Creating and Updating is whether or not you have passed it an ID value.
So, what can we do with it?
[ Discuss:

 * Breakout and examine the module_demo_counter().

 * Add dpm to the function so we can see the entity.
]
[entity]_delete
Saturday, October 24, 15
Deleting an entity - the “D” in CRUD - is also very similar.
Each entity type has an [entityname]_delete function, though again, at least in Drupal 7, they actually do not call a centralized entity_delete function.
I’m not going to demo that, but it works just like a load function.
One important thing, though - when you delete an entity through the user interface, you usually get a confirmation page asking you if you really want to
do that.
You do NOT get that with code. Delete a node with node_delete and it’s gone. Hope you have a backup.
[entity]_load_multiple
Saturday, October 24, 15
I want to draw your attention now to something you may have noticed earlier - the “node_load_multiple” function. Most entities have functions like this
one, which allow you to load *more than one* entity at a time.
In many cases, as we see here, they are used as an intermediary step between a single-loader function (node_load) and the entity_load function. It’s a
shortcut, essentially. entity_load can take multiple ids (as an array) and return multiple results (also as an array). node_load and its cousins are meant to
return only a single result, so they basically make use of their multiple load functions, but only pass them a single id value.
Interestingly, though, there’s nothing that is stopping you from using the [entity]_load_multiple functions yourself. Let’s take a peek at what that looks
like.
[ Discuss:

 * module_demo_counter_multiple()

 * performance concerns on loading many entities
]
Views & EFQ
Saturday, October 24, 15
Ok - so, we’ve seen a fair bit of what you can do with Entities and Fields.
Let’s talk about lists.
There’s basically two ways to do it in Drupal - Views, and Entity Field Query. They are vastly different, both very powerful, and have a lot of overlap in
what they can do.
Views
Saturday, October 24, 15
Views is the single most popular contributed modules in Drupal, according to statistics posted on drupal.org.
Views is, at its heart, a query generator - it generates a database query that pulls a list of entities, which can be filtered by any value in the entity.
So, you can use it to generate a list of all nodes of type “blog”, or all users born on your birthday, or all nodes tagged with a specific taxonomy term.
Probably the most appealing part of Views is that there is a UI for it - you can create a list of content without writing a single line of code.
Let’s take a look at a list like that.
[ Discuss:

 * Breakout to views admin, make character view with exposed filter on age range.
]
Views is good at...
• Making lists of content with any/all of their field data.
• Printing those lists in multiple places and ways (pages,
blocks, feeds).
• Filtering, especially based on user choices (exposed filters).
Saturday, October 24, 15
Views is not so good at...
• Being accessible and easily modifiable in code.
• Doing complex, inter-related queries.
• Performance.
Saturday, October 24, 15
Entity Field Query
(EFQ)
Saturday, October 24, 15
Entity Field Query, usually known as EFQ, is another way of generating a list, but this one has no UI. It’s all in code.
That does make it a little more advanced to use, in some ways, but it is pretty straightforward and there’s some great references out there. My personal
favorite was written by my friend and colleague, Tim Cosgrove, on the Phase2 blog.
[ Discuss:

 * Breakout to module, show module_demo_efq() - character list with filtering on gender.
]
EFQ is good at...
• Making lists of content by id.
• Working with in code.
• Filtering, based on values from code.
• Performance.
Saturday, October 24, 15
EFQ is not so good at...
• Being accessible and easily modifiable in a UI.
• Easily displaying output in pages or blocks (possible, but
not as easy; requires theming in code).
Saturday, October 24, 15
Senior Developer
Email: jturton@phase2technology.com
Joshua Turton
Twitter: @sjinteractive and @phase2
Drupal.org: srjosh
Saturday, October 24, 15
PHASE2TECHNOLOGY.COM
Saturday, October 24, 15

Contenu connexe

Tendances

Javascript Object Oriented Programming
Javascript Object Oriented ProgrammingJavascript Object Oriented Programming
Javascript Object Oriented ProgrammingBunlong Van
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Herman Peeren
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its TypesMuhammad Hammad Waseem
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHPHerman Peeren
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)mussawir20
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS ImplimentationUsman Mehmood
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and DestructorSunipa Bera
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonSujith Kumar
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryLaila Buncab
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptNascenia IT
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introductioncabbiepete
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript Dhananjay Kumar
 

Tendances (20)

Javascript Object Oriented Programming
Javascript Object Oriented ProgrammingJavascript Object Oriented Programming
Javascript Object Oriented Programming
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03
 
Solid OOPS
Solid OOPSSolid OOPS
Solid OOPS
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHP
 
Xtext Eclipse Con
Xtext Eclipse ConXtext Eclipse Con
Xtext Eclipse Con
 
Prototype Utility Methods(1)
Prototype Utility Methods(1)Prototype Utility Methods(1)
Prototype Utility Methods(1)
 
Ajaxworld
AjaxworldAjaxworld
Ajaxworld
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS Implimentation
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Jquery Introduction
Jquery IntroductionJquery Introduction
Jquery Introduction
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
 
About Python
About PythonAbout Python
About Python
 
Prototype Js
Prototype JsPrototype Js
Prototype Js
 

En vedette

The New Experience Team
The New Experience TeamThe New Experience Team
The New Experience TeamPhase2
 
Content Ops is Tops!
Content Ops is Tops!Content Ops is Tops!
Content Ops is Tops!Phase2
 
Making a (profitable) business Built on Open Source
Making a (profitable) business Built on Open SourceMaking a (profitable) business Built on Open Source
Making a (profitable) business Built on Open SourcePhase2
 
X All the Things: Total Content Control
X All the Things: Total Content Control X All the Things: Total Content Control
X All the Things: Total Content Control Phase2
 
Drupal distributions to build a platform
Drupal distributions to build a platformDrupal distributions to build a platform
Drupal distributions to build a platformPhase2
 
How 'Open' Changes Product Development
How 'Open' Changes Product DevelopmentHow 'Open' Changes Product Development
How 'Open' Changes Product DevelopmentPhase2
 
BassMaster Webinar hosted by Acquia
BassMaster Webinar hosted by AcquiaBassMaster Webinar hosted by Acquia
BassMaster Webinar hosted by AcquiaPhase2
 
Open atrium 2.0 at BADcamp
Open atrium 2.0 at BADcampOpen atrium 2.0 at BADcamp
Open atrium 2.0 at BADcampPhase2
 
Oa2 10 tips and tricks
Oa2 10 tips and tricksOa2 10 tips and tricks
Oa2 10 tips and tricksPhase2
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Phase2
 
Building applications-with-drupal
Building applications-with-drupalBuilding applications-with-drupal
Building applications-with-drupalPhase2
 
Accessibility Demystified: 3 Myths and Why They're So, So, So Very Wrong
Accessibility Demystified: 3 Myths and Why They're So, So, So Very WrongAccessibility Demystified: 3 Myths and Why They're So, So, So Very Wrong
Accessibility Demystified: 3 Myths and Why They're So, So, So Very WrongPhase2
 
Drupal Is Not Your Web Site
Drupal Is Not Your Web SiteDrupal Is Not Your Web Site
Drupal Is Not Your Web SitePhase2
 
Open Atrium 2.0 at Drupalcon Portland
Open Atrium 2.0 at Drupalcon PortlandOpen Atrium 2.0 at Drupalcon Portland
Open Atrium 2.0 at Drupalcon PortlandPhase2
 
The Yes, No, and Maybe of "Can We Build That With Drupal?"
The Yes, No, and Maybe of "Can We Build That With Drupal?"The Yes, No, and Maybe of "Can We Build That With Drupal?"
The Yes, No, and Maybe of "Can We Build That With Drupal?"Phase2
 
Site building with end user in mind
Site building with end user in mindSite building with end user in mind
Site building with end user in mindPhase2
 
Performance Profiling Tools and Tricks
Performance Profiling Tools and TricksPerformance Profiling Tools and Tricks
Performance Profiling Tools and TricksPhase2
 
How, When, and Why to Patch a Module
How, When, and Why to Patch a Module How, When, and Why to Patch a Module
How, When, and Why to Patch a Module Phase2
 
Site Building with the End User in Mind
Site Building with the End User in MindSite Building with the End User in Mind
Site Building with the End User in MindPhase2
 
Riding the Drupal Wave: The Future for Drupal and Open Source Content Manage...
Riding the Drupal Wave:  The Future for Drupal and Open Source Content Manage...Riding the Drupal Wave:  The Future for Drupal and Open Source Content Manage...
Riding the Drupal Wave: The Future for Drupal and Open Source Content Manage...Phase2
 

En vedette (20)

The New Experience Team
The New Experience TeamThe New Experience Team
The New Experience Team
 
Content Ops is Tops!
Content Ops is Tops!Content Ops is Tops!
Content Ops is Tops!
 
Making a (profitable) business Built on Open Source
Making a (profitable) business Built on Open SourceMaking a (profitable) business Built on Open Source
Making a (profitable) business Built on Open Source
 
X All the Things: Total Content Control
X All the Things: Total Content Control X All the Things: Total Content Control
X All the Things: Total Content Control
 
Drupal distributions to build a platform
Drupal distributions to build a platformDrupal distributions to build a platform
Drupal distributions to build a platform
 
How 'Open' Changes Product Development
How 'Open' Changes Product DevelopmentHow 'Open' Changes Product Development
How 'Open' Changes Product Development
 
BassMaster Webinar hosted by Acquia
BassMaster Webinar hosted by AcquiaBassMaster Webinar hosted by Acquia
BassMaster Webinar hosted by Acquia
 
Open atrium 2.0 at BADcamp
Open atrium 2.0 at BADcampOpen atrium 2.0 at BADcamp
Open atrium 2.0 at BADcamp
 
Oa2 10 tips and tricks
Oa2 10 tips and tricksOa2 10 tips and tricks
Oa2 10 tips and tricks
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
 
Building applications-with-drupal
Building applications-with-drupalBuilding applications-with-drupal
Building applications-with-drupal
 
Accessibility Demystified: 3 Myths and Why They're So, So, So Very Wrong
Accessibility Demystified: 3 Myths and Why They're So, So, So Very WrongAccessibility Demystified: 3 Myths and Why They're So, So, So Very Wrong
Accessibility Demystified: 3 Myths and Why They're So, So, So Very Wrong
 
Drupal Is Not Your Web Site
Drupal Is Not Your Web SiteDrupal Is Not Your Web Site
Drupal Is Not Your Web Site
 
Open Atrium 2.0 at Drupalcon Portland
Open Atrium 2.0 at Drupalcon PortlandOpen Atrium 2.0 at Drupalcon Portland
Open Atrium 2.0 at Drupalcon Portland
 
The Yes, No, and Maybe of "Can We Build That With Drupal?"
The Yes, No, and Maybe of "Can We Build That With Drupal?"The Yes, No, and Maybe of "Can We Build That With Drupal?"
The Yes, No, and Maybe of "Can We Build That With Drupal?"
 
Site building with end user in mind
Site building with end user in mindSite building with end user in mind
Site building with end user in mind
 
Performance Profiling Tools and Tricks
Performance Profiling Tools and TricksPerformance Profiling Tools and Tricks
Performance Profiling Tools and Tricks
 
How, When, and Why to Patch a Module
How, When, and Why to Patch a Module How, When, and Why to Patch a Module
How, When, and Why to Patch a Module
 
Site Building with the End User in Mind
Site Building with the End User in MindSite Building with the End User in Mind
Site Building with the End User in Mind
 
Riding the Drupal Wave: The Future for Drupal and Open Source Content Manage...
Riding the Drupal Wave:  The Future for Drupal and Open Source Content Manage...Riding the Drupal Wave:  The Future for Drupal and Open Source Content Manage...
Riding the Drupal Wave: The Future for Drupal and Open Source Content Manage...
 

Similaire à Fields, Entities and Lists in Drupal

Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)Tarunsingh198
 
Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!tedbow
 
Rupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritanceRupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritancerupicon
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cphcyberswat
 
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..Mark Rackley
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comJD Leonard
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your CodeRookieOne
 
Drupal - presentazione formazione sessione I
Drupal - presentazione formazione sessione IDrupal - presentazione formazione sessione I
Drupal - presentazione formazione sessione IGian Luca Matteucci
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui TestJohn.Jian.Fang
 
SharePoint Saturday St. Louis - SharePoint & jQuery
SharePoint Saturday St. Louis - SharePoint & jQuerySharePoint Saturday St. Louis - SharePoint & jQuery
SharePoint Saturday St. Louis - SharePoint & jQueryMark Rackley
 
Oop concepts classes_objects
Oop concepts classes_objectsOop concepts classes_objects
Oop concepts classes_objectsWilliam Olivier
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance TipsRavi Raj
 

Similaire à Fields, Entities and Lists in Drupal (20)

Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal 7 entities (stanford)
 
Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!Entities, Bundles, and Fields: You need to understand this!
Entities, Bundles, and Fields: You need to understand this!
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
.Net template solution architecture
.Net template solution architecture.Net template solution architecture
.Net template solution architecture
 
Rupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritanceRupicon 2014 Single table inheritance
Rupicon 2014 Single table inheritance
 
Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..
 
Ad507
Ad507Ad507
Ad507
 
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...
 
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.comDrupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
 
Spring boot
Spring bootSpring boot
Spring boot
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your Code
 
Drupal - presentazione formazione sessione I
Drupal - presentazione formazione sessione IDrupal - presentazione formazione sessione I
Drupal - presentazione formazione sessione I
 
BDD Primer
BDD PrimerBDD Primer
BDD Primer
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui Test
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Spsemea j query
Spsemea   j querySpsemea   j query
Spsemea j query
 
SharePoint Saturday St. Louis - SharePoint & jQuery
SharePoint Saturday St. Louis - SharePoint & jQuerySharePoint Saturday St. Louis - SharePoint & jQuery
SharePoint Saturday St. Louis - SharePoint & jQuery
 
Oop concepts classes_objects
Oop concepts classes_objectsOop concepts classes_objects
Oop concepts classes_objects
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
 

Plus de Phase2

Phase2 Health and Wellness Brochure
Phase2 Health and Wellness BrochurePhase2 Health and Wellness Brochure
Phase2 Health and Wellness BrochurePhase2
 
A Modern Digital Experience Platform
A Modern Digital Experience PlatformA Modern Digital Experience Platform
A Modern Digital Experience PlatformPhase2
 
Beyond websites: A Modern Digital Experience Platform
Beyond websites: A Modern Digital Experience PlatformBeyond websites: A Modern Digital Experience Platform
Beyond websites: A Modern Digital Experience PlatformPhase2
 
Omnichannel For Government
Omnichannel For Government Omnichannel For Government
Omnichannel For Government Phase2
 
Bad camp2016 Release Management On Live Websites
Bad camp2016 Release Management On Live WebsitesBad camp2016 Release Management On Live Websites
Bad camp2016 Release Management On Live WebsitesPhase2
 
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8Phase2
 
The Future of Digital Storytelling - Phase2 Talk
The Future of Digital Storytelling - Phase2 TalkThe Future of Digital Storytelling - Phase2 Talk
The Future of Digital Storytelling - Phase2 TalkPhase2
 
NORTH CAROLINA Open Source, OpenPublic, OpenShift
NORTH CAROLINA Open Source, OpenPublic, OpenShiftNORTH CAROLINA Open Source, OpenPublic, OpenShift
NORTH CAROLINA Open Source, OpenPublic, OpenShiftPhase2
 
Drupal 8 for Enterprise: D8 in a Changing Digital Landscape
Drupal 8 for Enterprise: D8 in a Changing Digital LandscapeDrupal 8 for Enterprise: D8 in a Changing Digital Landscape
Drupal 8 for Enterprise: D8 in a Changing Digital LandscapePhase2
 
User Testing For Humanitarian ID App
User Testing For Humanitarian ID AppUser Testing For Humanitarian ID App
User Testing For Humanitarian ID AppPhase2
 
Redhat.com: An Architectural Case Study
Redhat.com: An Architectural Case StudyRedhat.com: An Architectural Case Study
Redhat.com: An Architectural Case StudyPhase2
 
The New Design Workflow
The New Design WorkflowThe New Design Workflow
The New Design WorkflowPhase2
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Phase2
 
Memorial Sloan Kettering: Adventures in Drupal 8
Memorial Sloan Kettering: Adventures in Drupal 8Memorial Sloan Kettering: Adventures in Drupal 8
Memorial Sloan Kettering: Adventures in Drupal 8Phase2
 
Empathy For Idiots
Empathy For Idiots Empathy For Idiots
Empathy For Idiots Phase2
 
Open data + open government open goodness
Open data + open government open goodnessOpen data + open government open goodness
Open data + open government open goodnessPhase2
 
Open Source Logging and Metrics Tools
Open Source Logging and Metrics ToolsOpen Source Logging and Metrics Tools
Open Source Logging and Metrics ToolsPhase2
 
Open Source Logging and Monitoring Tools
Open Source Logging and Monitoring ToolsOpen Source Logging and Monitoring Tools
Open Source Logging and Monitoring ToolsPhase2
 
ReliefWeb's Journey from RSS Feed to Public API
ReliefWeb's Journey from RSS Feed to Public APIReliefWeb's Journey from RSS Feed to Public API
ReliefWeb's Journey from RSS Feed to Public APIPhase2
 
Thinking Inside the Box Inside the Box Inside the Box
Thinking Inside the Box Inside the Box Inside the BoxThinking Inside the Box Inside the Box Inside the Box
Thinking Inside the Box Inside the Box Inside the BoxPhase2
 

Plus de Phase2 (20)

Phase2 Health and Wellness Brochure
Phase2 Health and Wellness BrochurePhase2 Health and Wellness Brochure
Phase2 Health and Wellness Brochure
 
A Modern Digital Experience Platform
A Modern Digital Experience PlatformA Modern Digital Experience Platform
A Modern Digital Experience Platform
 
Beyond websites: A Modern Digital Experience Platform
Beyond websites: A Modern Digital Experience PlatformBeyond websites: A Modern Digital Experience Platform
Beyond websites: A Modern Digital Experience Platform
 
Omnichannel For Government
Omnichannel For Government Omnichannel For Government
Omnichannel For Government
 
Bad camp2016 Release Management On Live Websites
Bad camp2016 Release Management On Live WebsitesBad camp2016 Release Management On Live Websites
Bad camp2016 Release Management On Live Websites
 
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8
A FUTURE-FOCUSED DIGITAL PLATFORM WITH DRUPAL 8
 
The Future of Digital Storytelling - Phase2 Talk
The Future of Digital Storytelling - Phase2 TalkThe Future of Digital Storytelling - Phase2 Talk
The Future of Digital Storytelling - Phase2 Talk
 
NORTH CAROLINA Open Source, OpenPublic, OpenShift
NORTH CAROLINA Open Source, OpenPublic, OpenShiftNORTH CAROLINA Open Source, OpenPublic, OpenShift
NORTH CAROLINA Open Source, OpenPublic, OpenShift
 
Drupal 8 for Enterprise: D8 in a Changing Digital Landscape
Drupal 8 for Enterprise: D8 in a Changing Digital LandscapeDrupal 8 for Enterprise: D8 in a Changing Digital Landscape
Drupal 8 for Enterprise: D8 in a Changing Digital Landscape
 
User Testing For Humanitarian ID App
User Testing For Humanitarian ID AppUser Testing For Humanitarian ID App
User Testing For Humanitarian ID App
 
Redhat.com: An Architectural Case Study
Redhat.com: An Architectural Case StudyRedhat.com: An Architectural Case Study
Redhat.com: An Architectural Case Study
 
The New Design Workflow
The New Design WorkflowThe New Design Workflow
The New Design Workflow
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
 
Memorial Sloan Kettering: Adventures in Drupal 8
Memorial Sloan Kettering: Adventures in Drupal 8Memorial Sloan Kettering: Adventures in Drupal 8
Memorial Sloan Kettering: Adventures in Drupal 8
 
Empathy For Idiots
Empathy For Idiots Empathy For Idiots
Empathy For Idiots
 
Open data + open government open goodness
Open data + open government open goodnessOpen data + open government open goodness
Open data + open government open goodness
 
Open Source Logging and Metrics Tools
Open Source Logging and Metrics ToolsOpen Source Logging and Metrics Tools
Open Source Logging and Metrics Tools
 
Open Source Logging and Monitoring Tools
Open Source Logging and Monitoring ToolsOpen Source Logging and Monitoring Tools
Open Source Logging and Monitoring Tools
 
ReliefWeb's Journey from RSS Feed to Public API
ReliefWeb's Journey from RSS Feed to Public APIReliefWeb's Journey from RSS Feed to Public API
ReliefWeb's Journey from RSS Feed to Public API
 
Thinking Inside the Box Inside the Box Inside the Box
Thinking Inside the Box Inside the Box Inside the BoxThinking Inside the Box Inside the Box Inside the Box
Thinking Inside the Box Inside the Box Inside the Box
 

Dernier

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Dernier (20)

What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Fields, Entities and Lists in Drupal

  • 1. Fields, Entities and Lists, Oh My! October 24, 2015 Saturday, October 24, 15 Good morning everyone, and welcome to Fields, Entities and Lists, Oh My!
  • 2. Senior Developer Email: jturton@phase2technology.com Joshua Turton Twitter: @sjinteractive and @phase2 Drupal.org: srjosh Saturday, October 24, 15 [ Introduction of me ] Today we'll be talking about some important concepts and tools that are key to developing in Drupal 7 - Fields, Entities, and Lists. We’ll be talking about them mostly from a code perspective, so I’m going to make the assumption that you know at least enough to make a basic module and get Drupal to recognize and enable it. The things I’m covering today are all items I use practically every week, and a good working knowledge of them will make your life as a developer much more productive.
  • 3. Entities and Fields Saturday, October 24, 15 We’ll start with two of the most powerful and widely used tools in Drupal - entities and fields. Introduced in a limited fashion in Drupal 5 & 6 with "Nodes", they became standardized in Drupal 7, and they are everywhere in Drupal 8. Knowledge of what they can do and how to use them is critical. At their core, entities are units of information. They are PHP objects, defined by classes, which allow for the storage and manipulation of various types of data.
  • 4. Core Entity Types • Nodes • Comments • Taxonomy Terms • User Profiles Saturday, October 24, 15 These are the entity types that ship with Drupal core. Contributed modules greatly expand this list, and you can create your own entities as well! Drupal also allows you to define different "types" of those entities, to use for different purposes. [ Discuss: * Show Content Types * Talk about usefulness via Fields * Show Fields admin for node * Show Fields admin for taxonomy type, talk about standardization of interface ]
  • 5. Core Field Types (and their modules) • Textfield (text) • Textarea (text) • Textarea with Summary (text) • File (file) • Image (image) • Radio Buttons (options) • Checkboxes (options) • Single Select (options) • Multi-select (options) • Taxonomy Term (taxonomy) • Decimal (number) • Float (number) • Integer (number) Saturday, October 24, 15 These are the field types that ship with Drupal core. Contributed modules greatly expand this list, and you can create your own as well (though there are so many available that there’s rarely a case for that, honestly).
  • 6. Useful Contrib Fields (and their modules) • Date (date) • Date Popup (date) • Media (media) • Media YouTube (media_youtube) • Entity Reference (entityreference) Saturday, October 24, 15 These are just a few of the available field types that come from contributed modules, but they are some of my favorites. Indeed, I’d argue that at least some of these are pretty much essential.
  • 7. Aw, CRUD! • Create • Read • Update • Delete Saturday, October 24, 15 Drupal allows you to store and access information in the database directly - there is lots of functionality devoted to database interactions. So, how are entities different? Why would we use them instead of just storing information in the DB? One of the most powerful parts of Drupal has to do with what we call CRUD operations: Create, Read, Update, Delete. All of these entity types automatically define their own HTML forms to do those operations. You don't have to write a whole set of forms, form handling code, validations, database operations, and confirmation messages for each of them. It all happens automatically as soon as you turn on their module(s) and configure the types and fields. [ Discuss: * Break out to show Demo Site, edit node ]
  • 8. Using Entities and Fields in Code Saturday, October 24, 15 So, most of this is pretty basic stuff that you’re probably already using. So why am I showing it? Because all of this stuff exists in the code, too. Entities are standardized in their User Experience, but also on the code side too.
  • 9. entity_load Saturday, October 24, 15 Want to load an entity in code? Use [entityname]_load, and give it the id you want to load. All entity types have a load function. Now, what do I mean by “load” an entity? Loading an entity means, querying the database for one or more blocks of content, by id number. Drupal goes and gets the all the data from all the fields and tables related to that block of content, and assembles them as a PHP object, so that you can do whatever you need to do. This is the “R” - Read - in CRUD.
  • 10. node_load Saturday, October 24, 15 And all entity load functions implement the core function “entity_load”. Sometimes there’s a layer between them, but ultimately all entities work this way.
  • 11. [entity]_save Saturday, October 24, 15 Saving an entity - either a new one or one that already exists, is much the same. A new one would be the “C” in CRUD, for “Create”, while an existing one would be the “U”, for “Update”. Each entity type has an [entityname]_save function, though it’s worth noting that, at least in Drupal 7, they actually do not call a centralized entity_save function. However, they all work more or less the same way; you load or create a PHP object with the right values, then call the function and pass it that object. The difference between Creating and Updating is whether or not you have passed it an ID value. So, what can we do with it? [ Discuss: * Breakout and examine the module_demo_counter(). * Add dpm to the function so we can see the entity. ]
  • 12. [entity]_delete Saturday, October 24, 15 Deleting an entity - the “D” in CRUD - is also very similar. Each entity type has an [entityname]_delete function, though again, at least in Drupal 7, they actually do not call a centralized entity_delete function. I’m not going to demo that, but it works just like a load function. One important thing, though - when you delete an entity through the user interface, you usually get a confirmation page asking you if you really want to do that. You do NOT get that with code. Delete a node with node_delete and it’s gone. Hope you have a backup.
  • 13. [entity]_load_multiple Saturday, October 24, 15 I want to draw your attention now to something you may have noticed earlier - the “node_load_multiple” function. Most entities have functions like this one, which allow you to load *more than one* entity at a time. In many cases, as we see here, they are used as an intermediary step between a single-loader function (node_load) and the entity_load function. It’s a shortcut, essentially. entity_load can take multiple ids (as an array) and return multiple results (also as an array). node_load and its cousins are meant to return only a single result, so they basically make use of their multiple load functions, but only pass them a single id value. Interestingly, though, there’s nothing that is stopping you from using the [entity]_load_multiple functions yourself. Let’s take a peek at what that looks like. [ Discuss: * module_demo_counter_multiple() * performance concerns on loading many entities ]
  • 14. Views & EFQ Saturday, October 24, 15 Ok - so, we’ve seen a fair bit of what you can do with Entities and Fields. Let’s talk about lists. There’s basically two ways to do it in Drupal - Views, and Entity Field Query. They are vastly different, both very powerful, and have a lot of overlap in what they can do.
  • 15. Views Saturday, October 24, 15 Views is the single most popular contributed modules in Drupal, according to statistics posted on drupal.org. Views is, at its heart, a query generator - it generates a database query that pulls a list of entities, which can be filtered by any value in the entity. So, you can use it to generate a list of all nodes of type “blog”, or all users born on your birthday, or all nodes tagged with a specific taxonomy term. Probably the most appealing part of Views is that there is a UI for it - you can create a list of content without writing a single line of code. Let’s take a look at a list like that. [ Discuss: * Breakout to views admin, make character view with exposed filter on age range. ]
  • 16. Views is good at... • Making lists of content with any/all of their field data. • Printing those lists in multiple places and ways (pages, blocks, feeds). • Filtering, especially based on user choices (exposed filters). Saturday, October 24, 15
  • 17. Views is not so good at... • Being accessible and easily modifiable in code. • Doing complex, inter-related queries. • Performance. Saturday, October 24, 15
  • 18. Entity Field Query (EFQ) Saturday, October 24, 15 Entity Field Query, usually known as EFQ, is another way of generating a list, but this one has no UI. It’s all in code. That does make it a little more advanced to use, in some ways, but it is pretty straightforward and there’s some great references out there. My personal favorite was written by my friend and colleague, Tim Cosgrove, on the Phase2 blog. [ Discuss: * Breakout to module, show module_demo_efq() - character list with filtering on gender. ]
  • 19. EFQ is good at... • Making lists of content by id. • Working with in code. • Filtering, based on values from code. • Performance. Saturday, October 24, 15
  • 20. EFQ is not so good at... • Being accessible and easily modifiable in a UI. • Easily displaying output in pages or blocks (possible, but not as easy; requires theming in code). Saturday, October 24, 15
  • 21. Senior Developer Email: jturton@phase2technology.com Joshua Turton Twitter: @sjinteractive and @phase2 Drupal.org: srjosh Saturday, October 24, 15