Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Entity View Modes

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:02
    [Working with Entities in Drupal 7, Chapter 11, with Joe Schindelar]
  • 0:05
    Now that we've got a page on which we can view our entity
  • 0:09
    and we've seen how you can add fields to an entity,
  • 0:12
    I want to take a look at adding some additional view modes.
  • 0:16
    You've probably seen view modes before,
  • 0:19
    and the most common use case is the difference between
  • 0:22
    a full-page node and a teaser of a node
  • 0:25
    and that ability to configure fields and their displays,
  • 0:29
    so that some fields only appear in the teaser
  • 0:32
    and others only appear in the full view.

Entity View Modes


Probably the most common use case for view modes is teaser nodes. Or, a node being rendered in the teaser view mode. View modes allow entities to be displayed different depending on context, and also allow other modules like Field API that participate in the entity rendering process to adjust their behavior depending on the requested view mode.

In this lesson we’re going to take a look at an ‘authenticated’ view mode that we can use to adjust the display for any authenticated users. Then we’ll update Entity Controller class and make use of this new view mode in our ::view() method.

NOTE: in the video Joe forgot to change the 'member' label to "Member" and then later in the video when we view it in the UI it is corrected. The sample code included with this video has the correct label.

Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.