1

My users' profile pages contain a View with their 4 latest nodes. I would now like to add a "more" link underneath that View that redirects visitors to a page with all the nodes of that user.

I can easily create a View with all nodes of a specific user, but I don't know how to generalize this and create a page for every user. Am I making things too complicated? Maybe this is a triviality, but I can't find a solution on the internet...

3 Answers 3

3

Nope, that's totally fine. What you are looking for is the power of Views' built-in contextual filters. With that you can pass arguments from an URL to a view.

The classic example of how contextual filter values are provided to views is by the view path. If a view has the path example.com/my-view, the URL example.com/my-view/story/22 will call the view along with two values for contextual filters (in this case story and 22). But there are more ways of providing contextual filter values.

Just a rough outline so you can get the idea:

  1. Build a Views page with a path that contains a wildcard. Let's say it's usersnodes/%
  2. Build the "more" link on the user's profile page then to dynamically hold the user's uid. So that would be usersnodes/123 for example.
  3. In the view you created in step one now set the contextual filter (I think it's on the very right in the UI). There you have to possibility to grab an argument (or two, or three ...) from the URL and pass it as a contextual filter to the view to only get the nodes of the user whose uid was in the URL.
1
  • contextual filter is solution for this question , vote +
    – Yuseferi
    Commented Aug 30, 2015 at 4:38
0

Presuming, your existing view is a block display on the user profile page, it sounds like you're looking for the More link. Under the Pager setting in the Views UI there's an option add a more link below the pager.

enter image description here

If your view has a page display, the more link will link to it. That page display can have it's own display setting separate from other displays (e.g. all nodes instead 4 latest nodes).

0

Although @leymannx's answer works fine, I've figured out a slightly different solution, since I'm working with Panels and Views pages aren't considered as Panel pages. This is what I came up with:

  1. Build a View All nodes that displays all nodes of a user. I've done this by adding a new block to my View that showes a user's 4 latest nodes.

  2. Make sure the More link under the Pager setting of the View is set to yes. Change the Link display under the Advanced settings to, say, allnodes/!1.

We'll now create a page with this path.

  1. Add a new page All nodes and provide a placeholder %user in the path. For example: /allnodes/%user. Our created View and page don't necessarily need the same name; only an identical path is needed.

  2. Select your favorite Panel lay-out for the page and add the All nodes view to it.

  3. When users now click the More link in the View All nodes, they will be redirected to the appropriate All nodes page.

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.