0

I need to have a View that includes an author name with each node that also links to another View showing all the nodes by that author.

Currently I've got a home page View that always shows the most recent node for a particular content type. I added the field 'display name' (a custom field I created for users) to the View so it shows 'First Name' 'Last Name', and that works well.

I also see I can make it a link in 'rewrite rules' but that would be a hard-coded link to a particular author's page. It needs to be dynamic and link to whichever author's page belongs to the author writing the particular article that will be displayed in the View block.

Anyone know how to do this?

1 Answer 1

2

Assuming that authors are the user that created the piece of content and not an entity reference field, and that you're using D7:

  1. Create a clone of the current view that you're using, assuming that you want the author's list of nodes to have the same layout/fields/what have you that the current view you're working with does, and create a new page for it.
  2. For the path of the new view, create a path that includes a wildcard (%) such as /posts-by-author/%
  3. Under Advanced, add a Contextual Filter for Content: Author uid. When you put in a user's UID in the "Preview with contextual filters" box above the preview and hit Update preview, it should show you that user's posts.
  4. Now, back to your original view. Assuming that you're using a display format that requires fields, add the Content: Author uid field to your display and set it to "Exclude from display".
  5. Under "Add" there's a "Rearrange" option when you click the arrow next to the Add option. Rearrange the fields so that the UID field is above the name field. This will allow you to use it in the name field when you create a link.
  6. Under "Rewrite results" select "Output this field as a link" and enter the link path with [uid] replacing the wildcard symbol.

Now, when you click on an author's name, it should take you to a page that displays all the nodes created by that author.

0

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.