1

I'm developing a site using Drupal 8.2 and I have to create a page where the user can see which nodes he or she has viewed in the last 30 days. The goal is to provide a per user "browsing history" view with the recently read content ordered by date (ideally filtered by content type).

I've checked other similar questions about this topic and I've found the following suggested modules:

Unfortunately these modules don't have Drupal 8 releases at the time of writing this question (except the Message module which has a pre-release/alpha version).

I've also reviewed the official docs and found there's a core History module that tracks which nodes have been viewed by each user and when. I have this module enabled (it was enabled by default) and I've checked that it's actually collecting user interactions in the history table. According to the docs:

In Drupal 8 and later, the History module is included in Drupal core. When enabled, the History module records which user has read which content.

This only applies to authenticated users. Entities older than 1 month will always be shown as "read".

There is no UI provided, but history data is exposed to the Views module. You can add history data as a field to show "new" or "updated" node marks. You can also use a filter to only show content that is new or updated.

this module provides some kind of interaction with Views, so I assume it should be posible to create a view to show a list with links to each node viewed by the user. I've reviewed all the options in Views (filters, contextual filters and so on) and haven't found anything related to this history.

Is it really posible to create such a view? Any pointers on how to do that? Is there any other way to do this? How would you implement this funcionality in Drupal 8?

Cheers.

  • I am not sure whether this is already possible in Drupal 8, but in Drupal 7 you could definitely create a node Flag and a Rule that Flags a node when it is viewed. It is then very easy to create a View with all the Flagged nodes. These modules already have a Drupal 8 release, so you can give it a try. Let me know if this works, so that I can turn this comment into an answer. – Jeroen Feb 14 '17 at 22:57
  • It's worth a try indeed. I'm already using the Flag module to let users bookmark their favorite content and sooner or later I'll install the Rules module too to achieve other functionalities so I'll give it a try and let you know. Thanks! – Mikel Feb 15 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.