The core Drupal7 entity/field system as was available around 2010 was quite difficult to use. You can get a feel for them with this now historical article (and the 2 preceding ones that tell the history of Drupal7 entities), which shows how to make a minimal "fieldable" Drupal7 entity with a controller extending core
These are the original entity functions that core's
includes/common.inc made available:
Note the lack of an
entity_delete() function ?
Then along came the contribute Entity API module with some classic Create Read Update Delete (CRUD) functionality. A nice article showing you how to leverage the Entity API by creating and registering a controller extending
EntityAPIController (which itself extends
DrupalDefaultEntityController) is Build Your Own Custom Entities in Drupal – Setup (2014). It demonstrates a simple
project entity with some direct database table fields
id, name, description, deadline. It shows how to create a
project entity using
entity_create(), set its fields, and save it it using <code>entity_save(), and how to change how project pages are rendered by overriding
buildContent() in a
ProjectEntityController. But although one can interact with the fields of this simple entity, this is not yet what in Drupal7 is called fieldable and there are no bundles yet.
The next article in that series shows nicely how to make an entity fieldable (and also how to expose the entity to Views).
© Copyright 2001 - 2016 Webel IT Australia (ABN: 67 677 268 579). All rights reserved (except as specified below).
PHP code examples from Webel IT Australia on this site are distributed under the GNU General Public License.
Excludes text and code snippets from Drupal.org quoted for educational purposes.
Drupal’s online documentation is © 2000-2014 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0.
PHP code from Drupal.org is distributed under the GNU General Public License.
Drupal® is a registered trademark of Dries Buytaert.
Text quoted from Wikipedia for educational purposes is made available under the Creative Commons Attribution-ShareAlike License.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.
Site developed by Webel IT Australia.