by Jeff EatonOctober 17, 2011

Module Monday: Entity Construction Kit

The introduction of "entities" in Drupal 7 heralded a new era of flexibility and abstract nouns. The entity system allows existing Drupal data like comments, taxonomy terms, and user accounts to share much of the flexibility that nodes have long enjoyed, without forcing every type of data to adopt Node module's idiosyncrasies. Entities can use custom fields, but don't necessarily require robust content features like version tracking, translation support, and so on.

While programmers can define custom entities using their own modules, however, there's no way for site builders to create them from scratch. No way, that is, save the Entity Construction Kit.

Screenshot of administration screen

The Entity Construction Kit gives site builders a central screen in the Structure administration area of the site where they can define new entity types. Each entity type can have several built-in properties like creation dates, a simple on/off status flag, so on. Each entity type can also have multiple bundles -- when testing, I created a "Muppet" entity type with "Monster" and "Normal" bundles. Like any other entity type, you can attach custom fields to them to store whatever data you'd like: the "simple properties" are managed automatically by the Entity Construction Kit.

Once you've defined them, administrators and site builders with entity management permissions can create and edit individual entities. The resulting entities can be displayed to normal users, included in Views, and pointed to by other fields using the Entity Reference module.

For developers interested in taking the next step, it provides custom hooks for managing the entity types' display in code, and offers template code to override any entity type's controller class. By doing that, a developer can easily piggyback custom behaviors onto their newly defined entities without having to build them from scratch in code.

Screenshot of an entity being created

The Entity Reference Kit is still in early development: the Alpha 3 version of the module was just released, and a handful of known bugs can make using it bumpy for certain use cases. It's a great module to keep an eye on, though, and if you're tired of shoe-horning your data into nodes and taxonomy terms "just because they're there," it's a great way to explore the world of defining your own custom entity types!

Sign up for the Lullabot Newsletter and get our latest articles and more direct to your inbox

We can partner with you!

We’ve accomplished some amazing things for some really great clients. We’d love to talk about how we can help your next project!

Tell us about your project

You can be a ’bot!

We have an amazing team of friendly experts in a number of disciplines. We work hard, have lots of fun together, and take great care of our team.

See our open positions