8

On the page /admin/content, there is a column for Author. We have a lot of people editing our content, so the original author isn't all that important. I want to change it to show the last person that edited the content, which I believe is stored in the revision of that content. How can I modify the view to show that? Alternatively, is there a hook I can implement in a custom module to do this?

I've checked out a couple other questions like this one and this one, but they weren't much help.

1 Answer 1

8

Adding a relationship of user (content revision) & Content (Content revision) proved to be fruitless.

Ok, time for plan B

Using Views field view we'll create a revision view, add revision user as field and then insert this view as field on the content view.

1) Create a new view

  • Show: Content Revision

  • Checkmark Create a block

  • Items per block: 1

enter image description here

2) Add a contextual filter

  • Originally I tried with Revision ID, but there is a bug, this contextual filter does not work.
  • So instead use ID (which is the node id)

enter image description here

  • When filter not available, hide view

enter image description here

3)

  • Remove the changed & title fields
  • Add Revision User

enter image description here

4) Add a Sort of Changed

enter image description here

  • Select Descending sort

enter image description here

5) Save your view


Now go to the Content View (/admin/structure/views/view/content)

1) Add field of ID

enter image description here

  • Checkmark, exclude from display

enter image description here

2) Add field View

enter image description here

  • Select the view you just created and for contextual filter use {{ fields.nid }}

enter image description here

and that's it!

5
  • This worked out really nicely, thank you! I would have never guess there would be this many steps involved and I appreciate your screenshots. One question: the value appears empty for those pieces of content that were just created and not edited yet. Is there a way to fall back to the value of the original creator when there are no revisions? Commented Nov 7, 2018 at 17:41
  • And there are some others where there is a recent revision by a non-anonymous user, but it still shows up empty in the new column. Commented Nov 7, 2018 at 17:42
  • Actually, just removing the filter restriction on published content seems to do it. Although I am seeing a weird "off by one" issue in the view, where the last person to edit it appears exactly one row below where they should be. Any reason why that might be? Commented Nov 7, 2018 at 17:53
  • Final update: I had to switch {{ fields.nid }} to {{ raw_fields.nid }} to fix the "off by one" issue. Thanks again, accepting as the answer. Commented Nov 8, 2018 at 19:16
  • the value appears empty for those pieces of content that were just created and not edited yet. Is there a way to fall back to the value of the original creator @KimberlyW Add author as field, make sure field is arranged above the view field. Hide the author field if you like and then go to view field, scroll down a bit and click for no results behavior, click on replacement patterns and put the pattern for the author.
    – No Sssweat
    Commented Nov 8, 2018 at 20:35

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.