1

I'm trying to show a list of only the most recently published post by every user (not including the logged in user) in a view. What should my Views filters look like in order to accomplish this? I'm completely stuck!

enter image description here

At the moment, my view shows all posts from all other users. I now need to filter it down once more so that it ONLY shows the most recent post by all of these users.

Reference (issue):

enter image description here

1
  • @kenorb See edit :)
    – Brittany
    Commented Sep 27, 2017 at 17:11

2 Answers 2

4

The problem is that you are trying to filter based on two things:

  • Show the most recent content by an individual user.
  • Show each user.

In Views, you can generally only filter one kind of entity (content OR users) at a time.

However, there is a module that can help, Views Field View. This module lets you embed one view inside another.

So, you can do something like this:

  1. Create a view that shows the most recent content for a single user (takes a contextual filter of UID, returns one result, sorted by descending most recent).
  2. Create another view that shows all users except the logged in user. Use Views Field View module to embed the first view and show the most recent post by each user.

I haven't done this exact implementation before, but I've used Views Field View for similar things. There is a tutorial here.

If you use this module, do note this warning from the documentation:

Please note that using this module can impact the performance of your site, if the views being rendered are very resource-consuming. It's highly recommended to use this module in conjunction with other modules that provide views caching.

Good candidates to cache your views are the modules Views content cache and Cache Actions.

12
  • 1
    This is...so bad ass (if you don't mind me saying so). Lol. Works like a charm. THANK YOU.
    – Brittany
    Commented Sep 27, 2017 at 17:47
  • 1
    @Brittany Glad it worked for you. Note the potential performance problem and importance of caching (just updated my answer). Commented Sep 27, 2017 at 17:50
  • Just saw! Noted :) One small question: How can I have the first view return one result for each user? And not just return 1 item? E.g. right now, when I embed the view, it shows all users (great) but the filtered item is the same for all of them (e.g. all users show the item authored by uid 1)?
    – Brittany
    Commented Sep 27, 2017 at 17:51
  • @Brittany You will need to configure the views so that the child view receives the argument from the parent view. Refer to this tutorial: ostraining.com/blog/drupal/views-field-view Commented Sep 27, 2017 at 17:56
  • This tutorial shows me how to relate the views with taxonomy, but I'm still not sure how to specify that each user in the users view should show their own last post? The user list it self is correct, however each content item under every user is 202's last published item.
    – Brittany
    Commented Sep 29, 2017 at 5:25
1

Latest views Drupal 7 and 8 can do this without needing extra module

Add new view Show: Users

Relationships Add a relationshop "User: Representative node" Change "Representative sort criteria" to "Content: Updated date"

FIELDS Add a "Content:Title" field and make sure the Relationship is set to "Representative node"

Sort criteria Add a "Content: Updated date" to Sort criteria section and again make sure the Relationship is set to "Representative node" and also the "Sort descending" radio box is checked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.