Answers.Body: <p>I do not think there is an easy way to do this via the Drupal Views interface.</p>
  
  <p>However you can do it using jQuery or maybe CSS to hide all but the first instance of your repeating event.</p>
  
  <p>Start off by creating a custom event option field to identify each <strong>type</strong> of event. You could even use the event type ID if you wanted and just add more options to it.</p>
  
  <p>So it could be </p>
  
  <ul>
  <li>Jane's classes would have an ID of 1 </li>
  <li>Joe's classes would have an ID of 2</li>
  </ul>
  
  <p>So whatever you choose, each event will have an ID that identifies the type of event.</p>
  
  <p>You can get these ID values into the View. Make sure you have Civicrm Entities module installed.</p>
  
  <p>So now you have a view that shows say</p>
  
  <ul>
  <li><p>Start date</p></li>
  <li><p>Title</p></li>
  <li><p>Event type ID or your custom field ID</p></li>
  </ul>
  
  <p>Now you create a Row template for the View</p>
  
  <p>Now you wrap the row in a div and you add in a class to the div dynamically, from the event_type_id.</p>
  
  <p>So something like</p>
  
  <pre><code>&lt;?php $id = $fields['event_type_id']-&gt;raw;?&gt;
  &lt;div class="event_type_&lt;?php print $id;?&gt;"&gt;
  -----rest of the fields
  &lt;/div&gt;
  </code></pre>
  
  <p>If you inspect the output on the page, then each row for Jane's classes will be wrapped in this div</p>
  
  <pre><code>&lt;div class="event_type_1"&gt;
  </code></pre>
  
  <p>for example.</p>
  
  <p><strong>jQuery solution</strong></p>
  
  <p>Now what you do is make yourself a Drupal module that adds a bit of jQuery for when the page has loaded.</p>
  
  <p>It should have a function with a selector like this</p>
  
  <pre><code>$('event_type_1').slice(1).remove();
  </code></pre>
  
  <p>That would remove all but the first row of Jane's classes.</p>
  
  <p>Or this selector could do it</p>
  
  <pre><code>$('event_type_1:not(first-child)').remove();
  </code></pre>
  
  <p><strong>CSS solution</strong></p>
  
  <p>Add a class for the view using the Class option in Advanced section of Views admin for the view display.</p>
  
  <p>Then try</p>
  
  <pre><code>.view-class-added &gt; event_type_1:not(:first-child) {
  display: none;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-27T03:10:41.800Z
Answers.LastActivityDate: 2018-10-27T08:07:56.210Z
Answers.LastEditDate: 2018-10-27T08:07:56.210Z
Answers.UserDisplayName: Tony Horrocks
Answers.Body: <p>If you think that you can do it by using php code, i.e to filter only one event among the recurring events, then you can use the 'Views_php' module to obtain the component you want as field. You just need to call the function &lt;?php civicrm_initialize(); first and then start pulling the data you need with your code.
  You have many examples in online on 'how to use the views_php module?'.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-17T18:09:27.250Z
Answers.LastActivityDate: 2020-08-17T18:09:27.250Z
Answers.UserDisplayName: DAMO
Body: <p>[apologies for cross posting. This question is also on Drupal answers, but since the options for filtering would be based on civiEvent fields, I am posting here as well)</p>
  
  <p>We have a view that displays upcoming events. We use civiCRM for events. Some of our events are ongoing: they have the same title, but different dates. What logic could I use to display the next upcoming event, without displaying all upcoming events?</p>
  
  <p>For instance, at the moment the events displayed are based on date. Any event that is not yet passed will display in the view. But for a class which repeats 10 times, I do not want 10 of the same title, just the next class and its date/time. </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-25T18:46:41.213Z
Comments.Text: Is your view a calendar view or a list view?
Comments.UserDisplayName: Tony Horrocks
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-25T22:33:03.027Z
Comments.Text: list:  https://www.jewishideas.org/events
Comments.UserDisplayName: LaurynnLowe
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T12:21:24.030Z
Comments.Text: Not all that straightforward. The views output is unique to each event. So even if the titles are the same the dates are different. So you cannot use View Aggregation to get the results you want. I think you might have to do some views preprocessing and aggregate the view output on the event title so you just get a single views row per event title.
Comments.UserDisplayName: Tony Horrocks
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-28T04:26:23.970Z
Comments.Text: you might find that views_field_view could do what you need if you pass the Title over as the 'contextual filter' to another view, and have that view set up to only show 1 result that is in the future
Comments.UserDisplayName: petednz - fuzion
Tags: <civievent><drupal-views>
Title: For civiEvents in a Drupal View, how to display only one of a repeating event?
ThreadText: # For civiEvents in a Drupal View, how to display only one of a repeating event?
  
  (Asked by: username_0 on 2018-10-23)
  
  [apologies for cross posting. This question is also on Drupal answers, but since the options for filtering would be based on civiEvent fields, I am posting here as well)
  
  We have a view that displays upcoming events. We use civiCRM for events. Some of our events are ongoing: they have the same title, but different dates. What logic could I use to display the next upcoming event, without displaying all upcoming events?
  
  For instance, at the moment the events displayed are based on date. Any event that is not yet passed will display in the view. But for a class which repeats 10 times, I do not want 10 of the same title, just the next class and its date/time.
  
  **Tags:** civievent, drupal-views
  
  > **Comments:**
  > **username_1**: Is your view a calendar view or a list view?  
  > **username_0**: list:  https://www.jewishideas.org/events  
  > **username_1**: Not all that straightforward. The views output is unique to each event. So even if the titles are the same the dates are different. So you cannot use View Aggregation to get the results you want. I think you might have to do some views preprocessing and aggregate the view output on the event title so you just get a single views row per event title.  
  > **username_2**: you might find that views_field_view could do what you need if you pass the Title over as the 'contextual filter' to another view, and have that view set up to only show 1 result that is in the future  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-10-27. Score: 1
  
  I do not think there is an easy way to do this via the Drupal Views interface.
  However you can do it using jQuery or maybe CSS to hide all but the first instance of your repeating event.
  Start off by creating a custom event option field to identify each type of event. You could even use the event type ID if you wanted and just add more options to it.
  So it could be 
  
  Jane's classes would have an ID of 1 
  Joe's classes would have an ID of 2
  
  So whatever you choose, each event will have an ID that identifies the type of event.
  You can get these ID values into the View. Make sure you have Civicrm Entities module installed.
  So now you have a view that shows say
  
  Start date
  Title
  Event type ID or your custom field ID
  
  Now you create a Row template for the View
  Now you wrap the row in a div and you add in a class to the div dynamically, from the event_type_id.
  So something like
  raw;?>
  
  -----rest of the fields
  
  
  If you inspect the output on the page, then each row for Jane's classes will be wrapped in this div
  
  
  for example.
  jQuery solution
  Now what you do is make yourself a Drupal module that adds a bit of jQuery for when the page has loaded.
  It should have a function with a selector like this
  $('event_type_1').slice(1).remove();
  
  That would remove all but the first row of Jane's classes.
  Or this selector could do it
  $('event_type_1:not(first-child)').remove();
  
  CSS solution
  Add a class for the view using the Class option in Advanced section of Views admin for the view display.
  Then try
  .view-class-added > event_type_1:not(:first-child) {
  display: none;
  }
  
  
  ---
  
  ### Answer by username_3 on 2020-08-17. Score: 0
  
  If you think that you can do it by using php code, i.e to filter only one event among the recurring events, then you can use the 'Views\_php' module to obtain the component you want as field. You just need to call the function php civicrm\_initialize(); first and then start pulling the data you need with your code.
  You have many examples in online on 'how to use the views\_php module?'.</p
  
  
  ---
  
  