2

I'm having a block on the front page with a list of users displaying their profile fields like: picture, full name, e-mail etc. I achieved this by simply creating a User View in Views displaying it as a block.

Now I want to add an extra option to it that gives a list of the user's created node articles. So that their articles (per user) will be visible as a list and displayed like the profile fields.

I've tried several ways but all to no avail. The following approaches got me close:

  • Made a relationship "User: Representative node" and added a Node Title field to the View with this relationship. The way this relationship works is what I actually want, I think. The thing is: it obtains a SINGLE representative node for each user but I want to obtain ALL the nodes for each user.

  • Made a seperate user View (block) with relationship "User: Content authored" and contextual filter "Content: Author uid". Having the Node Title as a field again. I tinkered a bit with the contextual filter and setting it with "User ID from logged in user" gets me a nice list of nodes of the logged in user. But that's not what I want, I want to show all content of each user separately. Providing a default value "User ID from URL" gives me nothing. Probably because the block is on the frontpage.

Can anybody tell me what's the solution, or just give some ideas? I'm on it for days now and I'm out of ideas.

2

The simple "non-coding" version would be:

  1. install Views Field View module
  2. create a separate node view with a contextual filter that filters by node author
  3. in your first/initial view, add the "uid" as a hidden field
  4. in the same first/initial view, add a "views field" that is displaying the view created at point 2
  5. in this "views filed" settings add the uid field as an argument
  • Thank you so much Stefan, it works! I did try it with the Views Field View module already but never figured out how to setup the 2nd view properly. One question though: at step 2 I've to add a contextual filter, which I did. I assume that the option: "Display all results for the specified field" is the correct one instead of specifying a default value. – nerdrocker Oct 10 '15 at 20:09
  • 1
    There is no "correct/wrong" option. It all depends on your use case. I'll give you some examples: - if you want to use that view on the user profile page (on /user/[uid]), you can select "specify a default value" and then choose "user ID from URL" - in you plan to use the view in a broader context (e.g. a listing page), you can choose "display all results for the specified field" For your particular case, any option would work. – Stefan Oct 10 '15 at 20:37

Your Answer

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

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