Introduction to Drupal Entities and the Flexibility they Provide
With Drupal 8, just about everything that makes up the underlying architecture is considered an “entity”. This is a huge break from prior versions of Drupal as entities were broken up into distinct categories, such as node (page), field collection, and so on. Also, things like blocks (e.g. the header and footer of any site) were not considered entities.
Making (almost) everything an entity provides amazing flexibility. For example, as you can see from the screen capture to the right, just about anything can be referenced in a field. One example benefit is creating a block reference field. This amazing new architecture twist puts the power of adding reusable content in the hands of content editors with just a bit of a nudge from a site builder. How cool is that?
Beyond the flexibility provided, all things entity means the user experience for adding, editing, and deleting content is both easier and much more consistent now.
Entities are broken up into content and configuration entities. We cover Content Entities next.
Content Entities Built into Drupal 8 Core
The following content entities are built into Drupal 8 core, and may therefore be referenced by other entities:
- Content (pages)
- Blocks
- User Comments
- Menu Links
- Files
- Shortcut links (special menu links that live in the shortcut bar)
- Taxonomy terms (tags)
- Users
- Media added using the Media module
- Images
Some contributed modules provide additional entity references.
Example Use Case: Reusable Blocks
Let's tie everything together to help understand the reason Drupal 8 is so much more flexible.
Suppose you wanted to create reusable blocks for displaying several different types of ads on your site. Traditionally reusable blocks were limited to sidebars, the header, the footer, and other pre-designated regions provided by your Drupal theme.
What is a Drupal Theme? Think of themes as the Website's skin. Themes dictate the look and feel of Drupal websites. Themes are made up of template files, HTML (page structure), CSS (page design), Javascript (dynamic page elements), media specific to your site, and other assets. Themes typically provide a great starting point for your design, and can often be tweaked to give you the design you envisioned. There are hundreds of free and premium license-based themes that can be purchased for under $50.
Now you can create all your ads, then place them anywhere you'd like using the core Drupal 8 Layout Builder module. We can't even begin to tell you how awkward it was trying to pull something similar off in prior versions of Drupal.
Let's now take the example one step further. If both the page you're adding and a given ad had the same taxonomy term (tag) assigned to them, you could show all ads in the same category (i.e. with the same tag) in a dynamic rotating fashion. Neat!