8

Currently a user needs to click through to an Event info page before they know if it is full or not.

Is there a way to take this information:

"This event is currently full."

and display it in a Drupal View/ Pane?

5

One approach would be to use the views_php module to embed a civicrm_api3 call to find out if the event is full, then print the result into the view. E.g.

$event = civicrm_api3('Event', 'getsingle', array('return' => 'is_full', 'id' => $row->id));
if (!empty($event['is_full']) {
  print "Event is full";
}
  • 1
    You can get the is_full value from the event get api call and requesting "return.is_full" in the params – Donald Lobo May 7 '15 at 15:52
  • Two years later is still one of the best solutions? – Francesc Bassas i Bullich Jun 16 '17 at 8:47
4

We have been using the module "views conditional" to do that. Here's how it works:

  1. install and enable the module "Views Conditional"

  2. enable the relationship Event -> Participant in the view

  3. activate aggregation in the view in order to count the number of participants (hide it if necessary)

  4. add the field to the view: (Event -> Participant) COUNT(CiviCRM Participants: Participant ID) (hide it if necessary)

  5. add the field to the view: CiviCRM Events: Event Max-Participants

  6. add a global field (math expression) to the view and calculate the remaining places. The math expression could look like this (but depends on the name of your fields: [max_participants] - [id_1]

  7. add a views conditional field and define it similar to this: Views: Views Conditional (If expression is Less than 1, output FULLY BOOKED, else output REGISTRATION AVAILABLE) (also see screenshot)

Be aware that this approach is also kind of a workaround and has some shortcomings. For example, the aggregation function would also count cancelled participants. You could set a filter but it may have undesired results on your view (such as not showing events without a registration).

Nevertheless, the views conditional module in combination with the aggregate function may open up new possibilities for you. Just make sure to test properly before productive use.

3

In the Drupal extension CiviCRM Entity 7.x-2.0-beta9 release there is a new feature that allows to check if an event is full as view extra.

CiviCRM Views Extras -- Added Views field handler for CiviCRM Events - Event is Full - True if event is full false otherwise

2

Yes you can. You can create your own views based upon the CiviCRM event data what you need to do is probably build a check in your view which compares the number of registered people of the number of available places.

2

Just had to set this up, and the combo of civicrm entity 2.1 and views conditional works really well.

Make a view of civicrm event type. Add the "event is full" field and then make the views conditional based on whether event is full is 0 or 1.

1

We experience the same challenge. I see a solution with the views_php module but that is not a recommended module. Another way would be to use a custom event field that has the number of registered people (filled after every registration by a custom extension). That field would be available in the views module. But easier would be if there was a way provided by civicrm core to retrieve the number of registered people in a view. That field I believe is not available (yet).

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.