0

This may have an embarassingly simple answer - apologies if I've missed it!

When participants come to our events, we want to know what other events they have been on, or are booked on.

I can make a Drupal View of participants and use table aggregator plus to group rows by person - enumerating that grouped row lists all the events a person has been on. But if I then filter the list by the event I'm interested in - of course we are only showing the single participation of each person on the event I filtered for. No more list of all events.

I suppose we could make a group of the event participants and filter the view based on that, but it is all seeming a rather long way round to an issue that must already have come up.

I'll be grateful for any ideas!

Civicrm 4.7.27, Drupal 7.56

2

You can create a block using view.

Below exported view will list all events the logged in user is being registered.(To test you will need to import the views using below code)

$view = new view();
$view->name = 'event_listing';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'civicrm_participant';
$view->human_name = 'Event listing';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Events';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: CiviCRM Events: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'civicrm_event';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['link_to_civicrm_event'] = 'page';
/* Contextual filter: CiviCRM Participants: Participant's Contact ID */
$handler->display->display_options['arguments']['contact_id']['id'] = 'contact_id';
$handler->display->display_options['arguments']['contact_id']['table'] = 'civicrm_participant';
$handler->display->display_options['arguments']['contact_id']['field'] = 'contact_id';
$handler->display->display_options['arguments']['contact_id']['default_action'] = 'default';
$handler->display->display_options['arguments']['contact_id']['default_argument_type'] = 'php';
$handler->display->display_options['arguments']['contact_id']['default_argument_options']['code'] = 'civicrm_initialize();
return CRM_Core_Session::singleton()->get(\'userID\');
';
$handler->display->display_options['arguments']['contact_id']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['contact_id']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['contact_id']['summary_options']['items_per_page'] = '25';

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
  • Thanks so much Pradeep! This is great for seeing all the events of a logged in user. If you get a chance (but no hurry and no problems if it's too much to ask) I'd be most grateful to learn how the php code in the contextual filter works, or if you could point me in the right direction. I'm not a php programmer, but able to understand essential concepts. Once again, thanks for your help. – Andyg8 Jan 16 '18 at 12:54
  • The code will return civicrm contact id of logged in user. All the events are registered with CiviCRM contact id and is tied with drupal user. So i used contextual filter to display all the events of a contact id who is logged in. Please close the question as answered if you feel i have answered your question correctly. Thank you so much! Cheerz – Pradeep Nayak Jan 17 '18 at 3:23
  • Thanks Pradeep, very helpful. The question is not quite answered - while it's very helpful to know how to display all the events for a logged in user, I was actually hoping to show all the participants on an event, with a list of the other events they have registered for (past and present), within each participant's row. This enables us to get a quick overview of the participant's engagement with us before they come to the event. – Andyg8 Jan 17 '18 at 17:42
  • I did subsequently discover this is possible using a View of participants and including a 'Views Field View' of another view that shows the events per person. But that route seems very clunky and is prone to out-of-memory issues. I was thinking there must be an easier way! – Andyg8 Jan 17 '18 at 17:43

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.