Thumbnail

Create a user article view with EVA

Thumbnail

Campbell Tilley

|

Want to create a view to display articles on your User entity pages? The EVA module allows you to attach views to entity types other than Content.

When you install a basic version of Drupal, you are given two content types: Pages and Articles. Drupal adds the author into the articles, allowing you to click and look at the author which is a User entity type. Wouldn't it be nice if you could see other articles written by the author when you view their page? Out of the box Drupal doesn't give you this functionality. With Views, you are limited to displaying them on your Content entity types. With the EVA module, you can configure your view to be shown on the User entity and just about any other entity you have on your site too.

Let's look at how to set up EVA in a User Article view...

  1. Begin by downloading EVA from Drupal.org and enable it on your site.
  2. Create a block view showing Content.

  3. Configure your block view settings such as Display type, Filter and Sort criteria. Below is an example of the Lil Engine view. We have also used an output of 3 items per page with a full pager.

    Thumbnail
  4. For this view, you will need to add a Contextual filter for Content: Authored by. This filter will need the following settings:

    • When the filter value is not available: Provide default value

    • Type: User ID from route context

    • Also look for a node and use the node author

  5. Click the +Add button under Displays and select EVA. This will copy your current settings and add a new EVA tab.

  6. Under Entity content settings click on Entity type and select User from the list. For good measure, select User for the Bundle too.

  7. Save your View and head over to the Block layout page.

  8. Place your block in your desired region then set the Pages shown to /user/*.

EVA will wave it's wand and just like magic, your Author's articles will be displayed on the user pages. If you would like to see this module in action, click on my name at the top of the article.

Spread the word