Understanding Drupal 7 Entities

Drupal 7 introduces a new model for storing content and at the heart of the change is the invention of entities. One of the keys to Drupal’s success has always been its simplicity and consistency in handling different data types. In D6 and earlier we could basically say that in Drupal “everything is a node”. However, certain data was not stored as a node, including comments and users.

With the introduction of entities we now have an all-encompassing way of storing all content including comments, nodes and taxonomy items. Each of these different types of data are now stored as entities. Another way of viewing an entity is that it is a container for data, allowing Drupal to provide consistent handling across multiple data types. For object-oriented programmers, you might also think of an entity as an object that can be manipulated and altered.

A major practical gain from the invent of entities is fieldability. In D7 the fielding options that were previously available in CCK module are now core. And instead of fields being only available for nodes, fields can now be added to any fieldable entity. This allows us to add custom fields to taxonomy terms and user profiles.

Resources for Working with Entities

Tutorial on drupal.org on how to create a new entity.

Function hook_entity_info. Used to inform the base system and Field API about entities.
Function entity_get_info. Used to load information about an existing entity.