Creating a view that shows all events and the users that have signed up for each event

drupal.stackexchange https://drupal.stackexchange.com/questions/1749

  •  16-10-2019
  •  | 
  •  

Question

I am using the Signup module, and I am looking to create a view that shows all events and the avatars (default Drupal user picture field) of the users that have signed up for each event.

Here is a mockup of what I am trying to achieve. I have everything but the avatars so far.

View Mockup

See export of the View I have so far

Was it helpful?

Solution

Doing something like this is pushing views to it's limits. You want to pull in a lot of data and group it by the node id. I'm not sure if all this is possible through the views interface, though I believe it will be possible with the engine that's running views.

Instead of trying to achieve this rather complex view, which may become something, that's hard to modify, you could do this quite easily using more and simpler queries. Such a simple solution could look like this:

  1. You could create a simple view, which display all the info except the signups. (Node title etc)
  2. Signup already has a view, which will display the people that signed up for an event. With a little bit of modification, you could make it show the avatar of the users that has signed up for an event. Then you could embed this view in either a preprocess function and/or a template for the view you created in step 1.
  3. You're done.

The ideal thing would be to create all of this in a single view, but sometimes you have to think about what the cost will be compare to the gains. I doubt you will be able measure any performance differences, unless you list hundreds if nodes with signups. But the time you save doing it this way is quite a lot.

This is the same with views itself, it's inefficient, but nothing important (for most sites) and it allows us to save lots of time, not having to code queries, theme functions etc.

Update:

Embedding a view with arguments (like node id) is pretty simple:

$html = views_embed_view($name, $display_id, $arguments)

Or in your case

$html = views_embed_view('signup_user_list', 'default', array('nid' => $nid));

OTHER TIPS

Create a "Group" named "Event". You don't need to install all of the OG modules, just a few. You dont need to create a group content type: you simply need an "Event".
People create Events and join Events. Go into group default permissions and make the group public by allowing people to join the event without subscribing.

You may want to use the "String Replace" module to easily customize some of the language to your liking, or over-ride the group theme functions. "String Replace" is simple and fast, but can be a bit too universal (it's up to you). Either can help make the language of joining to be just as you want. The template over-ride will allow you to make additional changes to the user interface.

Use a view, and a custom template.tpl.php! Done! Its fast, light weight and easy. Users will never know they are joining a "Group" and the results you get will exactly match what you want. Easy as PIE!

Add a user reference to your content type if it doesn't already include one and include it on your view with a relationship.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top