3

I may not have the correct terminology here but please allow me to explain what I am trying to do.

I have a view that shows pictures that users have uploaded and that require approval. I am handling approval through the Flag module (administrators flag a node to approve it).

I have created a view that shows all the unflagged nodes containing pictures that are awaiting approval.

Now, on this view, for each picture that a user has uploaded, I would like to show all the other pictures that the author has uploaded (Users are limited to uploading five pictures, so this can't get too crazy. Each picture is its own node.)

To do this, I tried creating a view display attachment that shows all the pictures uploaded by a user (limited by a Contextual filter of author: uid). I then attached this to my main view, but the contextual filter's value is not added per row. I may be misunderstanding how views attachments work; I've never used them before.

Am I configuring this wrong? Is there a different approach that I should be taking?

In short, this is what I am trying to achieve:

  • The main view shows each picture (stored as an individual node) that needs to be approved.
  • Next to each picture that is pending approval, I would like to show all the pictures uploaded by that user (stored as individual nodes) that have already been approved.
2
  • I haven't tried anything like this, but you might be able to use viewfield to add the "sub-view" to the user entity, then just include that field in the main view where it should render. Not ideal for performance but I don't think there's any way to do this that wouldn't take a big-ish hit
    – Clive
    Commented Aug 10, 2013 at 13:47
  • @Clive Ok, I'll try it. This is just an admin approval screen, so performance is not a big concern; accuracy of approval is far more important. Commented Aug 10, 2013 at 14:02

2 Answers 2

2

1) Viewfield is a good solution.

Views attachment attach to a views display (Page, Block etc) not to each row.

So, first remove the Contextual filter uid.

Then add one more field, the flag of the node. Then you will have User_Name, Node Image, Flag and each row will represent a node.

2) Another option is to use the Views_Merge_Rows. In the Merge Rows settings you have to set the Merge Options for the User Name field as "Use the values of this field as filter" and uncheck the "Exclude this field from display". For the other fields select the "Use the first value of this field".

3) If you don't want to use a contributed module use the "Group results together" on the Format display settings. Group by user name and then Exclude from display the User Name field.

2

You can also use Views Field View in order to add a field that represents another View. Each row will have that field.

In order to achieve what you want, you will have to add the new field and specify which contextual filter you want to pass to the other View. You will be able to select tokens from other fields of the same row.

That another view, which will be a Block display with the appropiate contextual filter, will receive the token and display the correct fields (pictures in your case).

Take into account that embedded views may produce a slow performance. So you may also want to use views caching. Different modules provide Views caching (e.g. Views Content cache and Cache Actions).

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.