User login

Fields, Bundles, and Entities in Drupal 7

Karoly Negyesi (chx) mentioned in IRC "one thing people (like rszrama) is using entities is basically multigroup functionality." "Say, you have something like a line item in an invoice, needs a lot of fields, that becomes an entity. And it's not a node because a node has stuff like promote and sticky which does not apply."

Fields

borrowing from Barry Jaspan, http://www.archive.org/details/DrupalconDC2009-FieldAPIDrupal7

defined Field CRUD API
we now have an API for developers to use fields for storage.

any entity can use field attach.

including things possibly not in the Drupal database

Field storage is pluggable. In core, field SQL storage. Can change the default used for all fields, or use different storage, including offsite storage, for specific field types.

Fields = field types.
Field instances = a field (type) attached to content type, a comment, a vocabulary, or any other fieldable entity.
Bundle is the term we use to describe something that has a given set of fields attached to it. Typically, this is a content type, but again, it can be a vocabulary or any fieldable entity.

All documented.

Field on users.

Barry Jaspan: A node is the basic unit of content whose natural [place of residence] is in the Drupal database. The defining property of a node

All the field-related database tables begin with field_.

Single, unlimited, or n number of fields

We made entity type a numeric ID that references a table with its name (usually node, user, or comment) because it is constantly being used with the entity ID to select, and joining on a varchar is slow in relational databases.

How Fields got done:
Code sprint in December
Yves C
David Strauss
Florian Loretan
Moshe Weitsman
Karen Stevenson
Barry Jaspan
Karoly N
sponsored by many companies and individuals, including Achieve Internet, Acquia, Four Kitchens, Now Public, Karen Stevenson, Yves, and Moshe.

All per-field storage allowed the throwing out of thousands of lines of code.

There's a node field cache.

If you're putting 100 fields in a view, then you should load the node, which is cached.

http://api.drupal.org/

Searched words: 
What's an Entity? and fields

Comments

Bundles

Is there any concept of sub-bundles in D 7..??for example..i have some fields bundled by different names..and i want to refer to these bundles via a super name.bundle..?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.