Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughHow to Use Entity Reference Views in Drupal 7
Entity Reference Views are one way you can make life easier for Drupal content creators.
Normally, when people are creating content on your site, each field consists of a single box with a single data point. For example, in a list of people, you might get only the person's name.
Entity Reference Views allows you to provide far more information. For example, you can add photos and personal details to your list of people.
Entity Reference Views in Drupal 7
In this example, I have a content type called "Presentations" and another content type called "Speakers". Every time I add a presentation, I want to choose from a list of speakers.
- Install and enable Views and Entity Reference.
- Go to Structure > Views > Add new view.
- Create a view of the content that you want content editors to choose from. In this example, I'm going to make a list of "Speakers":
- At the top of the page, click "Add" then "Entity Reference":
- Click "Settings" next to "Entity Reference list".
- Search fields: Choose the field you want users to search by.
- Click "Apply (this display)".
- Check the preview to make sure your view is working ...
Step #2. Add a Field with the Entity Reference View
- Go to Structure > Content types.
- Add an "Entity Reference" field.
- Target type: Choose to link to nodes, users, files or whatever else you want to display.
- Mode: Choose "View: Filter by an entity reference view."
- View used to select the entities: choose the view you created.
- Click "Save field settings".
- Click "Add content" and the data entry for your field will use the View you created:
Entity Reference Views Widget
It's possible to extend this module by using Entity Reference View Widget. This places your view inside a pop-up box to make it easier to select items.
There's a tutorial here and this video has guidance:
Entity Reference Views in Drupal 8
Both Views and Entity Reference are now part of the Drupal 8 core. To use Entity Reference Views in Drupal 8, the process is like this:
- Create a view, as we showed above.
- Go to Structure > Content types > Add field.
Click through the settings and under "Reference type", you can choose "Views: Filter by an entity reference view".
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web