You are previewing Programming Drupal 7 Entities.

Programming Drupal 7 Entities

Cover of Programming Drupal 7 Entities by Sammy Spets Published by Packt Publishing
  1. Programming Drupal 7 Entities
    1. Table of Contents
    2. Programming Drupal 7 entities
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Using the example code
      5. Conventions
      6. Reader feedback
      7. Customer support
    9. 1. Understanding Entities
      1. Introducing entities
      2. Entity and solution modules
      3. Introducing entity types, bundles, and fields
      4. Powerful entity use cases
      5. Our use case
      6. Summary
    10. 2. Developing with Entity Metadata Wrappers
      1. Introducing entity metadata wrappers
      2. Creating an entity metadata wrapper object
      3. Standard entity properties
      4. Entity introspection
      5. Using an entity metadata wrapper
      6. Safely using text property values
      7. Self-imposed limitation of entity programming
      8. References
      9. A note about EntityFieldQuery
      10. Summary
    11. 3. Developing with Non-fieldable Entities
      1. What are non-fieldable entities?
      2. File entities
      3. Vocabulary entities
      4. Recipe site vocabularies
      5. Summary
    12. 4. Developing with Fieldable Entities
      1. What are fieldable entities?
      2. Node entities
      3. Comment entities
      4. Term entities
      5. Summary
    13. 5. Developing with Fields
      1. Field types
      2. Single-value and multi-value fields
      3. Structure fields
      4. Converting the recipe content type to use fields
      5. Summary
    14. 6. Developing with Field Collections
      1. Before Drupal 7
      2. Creating a field collection field
      3. Field collection entities
      4. Adding a field collection to a node
      5. Attaching a field collection to a content type
      6. Summary
    15. 7. Expose Local Entities
      1. Motivation for exposing entities
      2. Fast track your data exposure
      3. Allow fields on your entity
      4. Give it multiple bundles
      5. Administration interface and exportability
      6. Summary
    16. 8. Expose Remote Entities
      1. Introducing the Remote Entity API
      2. Requirements for exposing remote entities
      3. Implementing remote entity exposure
      4. Running
      5. Adding write support
      6. Customization for your use case
      7. Summary
    17. Index
O'Reilly logo

Structure fields

Now that we've successfully distinguished single-value and multi-value fields, we have to get around one last, very nasty trap before we can cook code with wrapped fields. The trap: some fields are neither lists of values nor just values. For these fields we can't use the value() method directly and have to resort to other means. We will call these types of fields structure fields.

Structure field wrappers are either of the EntityDrupalWrapper class or the EntityStructureWrapper class. The former class means that the field wrapper is wrapping an entity. In our example, code for printing EntityDrupalWrapper values would look as follows:

function pde_entity_value($entity_wrapper) { return pde_output($entity_wrapper->label()); } ...

The best content for your career. Discover unlimited learning on demand for around $1/day.