Answers.Body: <p>If this is on Drupal, you could generate a View that displays links to the webform and form the link with each event's event id in the URL.</p>
  
  <p>Add a new view of CiviCRM Events.<p>
  This will add the event id field.  Under settings for that field, check Exclude from Display and make sure for Thousands Marker you change it from comma to none.<p>
  Add the start date field.<p>
  Add a Global Custom Text field.  In the Text area put Register for this Event (or something like that).  Under Rewrite results, select output this field as a link.  This is where you will link to the webform prefilled with the correct event id.  I don't do much work with events, but according to the help on the webform integration:</p>
  
  <blockquote>
    <p>Allow events in "User Select" mode to be auto-filled from URL.</p>
    
    <p>Example for "Register all":
    <a href="http://example.com/node/" rel="nofollow">http://example.com/node/</a>{node.nid}?event1={event1.event_id},{event2.event_id}</p>
    
    <p>Example for "Register separately":
    <a href="http://example.com/node/" rel="nofollow">http://example.com/node/</a>{node.nid}?c1event1={event1.event_id},{event2.event_id}&amp;c2event1={event3.event_id}</p>
  </blockquote>
  
  <p>So your rewrite might be something like node/1?event1=[id] where node/1 is the path to your webform.</p>
  
  <p>On the webform civi settings under event, make sure you have "Allow events to be autoloaded from URL checked."</p>
  
  <p>Then under the view's filter section add start date, change the operator to "Is greater than," in the Value area, change it to An offset from the current time such as "+1 day" or "-2 hours -30 minutes" and in Value field enter Now.<p>
  This should give you a view of all upcoming events with a link to the webform prefilled with the correct event.<p>
  You'd need to add some more filters to get just what you need and add a sort by start date, but this should get you in the ball park.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T10:04:40.050Z
Answers.Text: I had this working on a test site (it still does) but cannot get it working on a live site.  I can see that the events code works as it shows me the events correctly selected, but the webform shows nothing selected ( - None - ). I can't see any differences between the sites (views & webform same release level) but there must be something.  How is the link made between the view and the webform? If I could understand that maybe I could figure out what's wrong - as that seem to be the problem.  Thanks for your help!
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T11:18:32.793Z
Answers.Text: Just an idea. Hover over the link and see if the event id has a comma in it.  If it does, edit the view and make sure that the thousands marker is set to none.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T13:22:16.830Z
Answers.Text: Forgive my ignorance (& thanks for the quick response) but which link?  I did set the thousands marker to none for the event id field.  The link I have in the global custom text field is 'node/27?event1={event1.event_id},{event2.event_id}'   I tried an absolute url but no difference.
  I feel pretty sure that views is working fine, for some reason webform isn't picking it up.  But I don't understand how they talk to each other so hard to know what to do next.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T14:08:38.093Z
Answers.Text: I believe the link should be node/27?event1=[id].
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T14:26:41.933Z
Answers.Text: By the link, I meant the one generated by the view.  Views basically pre-fills the webform by telling it fill out this web form (in your case node/27) with this event (event id).  [id] is the token in the view that specifies which event you're referring to.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T14:44:36.130Z
Answers.Text: Thanks for the explanation - I tried the link you suggested but again webform didn't use it. In fact I saw that link in Views by hovering over the link for the first selected event - the url was https://www.dcm-admin.org.uk/node/25?event1=163#overlay-context=civicrm/admin/setting/updateConfigBackend%3Freset%3D1 and if you click on  that link it takes you to the webform with that event selected.
  I'm wondering if a bug had crept into the latest webform modules as this was working...
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T15:01:33.847Z
Answers.Text: View is formed correctly then it must be webform related.  Are you sure Allow events to be autoloaded from URL is checked.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-28T15:02:16.573Z
Answers.Text: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/32243/discussion-between-andy-clark-and-paul-mosey).
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T16:08:03.223Z
Answers.Text: It is Drupal - can you explain a bit more how Views could generate a default event- I guess based on today's date?
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T16:38:41.200Z
Answers.Text: Added detail to answer.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T17:54:14.003Z
Answers.Text: Thanks for this very detailed explanation - almost there with this!
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T18:40:22.030Z
Answers.Text: Terrific - worked 100%.  Thank you so much!  I have not used Views much but obviously it's very useful stuff to know.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T18:42:15.477Z
Answers.Text: Glad it worked.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T15:48:54.647Z
Answers.LastActivityDate: 2015-09-27T16:38:26.760Z
Answers.LastEditDate: 2015-09-27T16:38:26.760Z
Answers.UserDisplayName: pmoz
Body: <p>Using webform I have created event registration for a nightshelter that runs continuously for 4 months at various different churches. I have set this up as a repeating event so each day is a different event - there are good arguments for doing it this way. I would like to have the 'current' event - which is today's nightshelter - as the default event. Is that possible or is there a hook I can use?  Having a default event each day is the problem, otherwise the user is going to have to choose from 122 events!</p>
  
Tags: <webform-civicrm><4.6.8>
Title: How to select a default event in webform where event is repeating
ThreadText: # How to select a default event in webform where event is repeating
  
  (Asked by: username_0 on 2015-09-27)
  
  Using webform I have created event registration for a nightshelter that runs continuously for 4 months at various different churches. I have set this up as a repeating event so each day is a different event - there are good arguments for doing it this way. I would like to have the 'current' event - which is today's nightshelter - as the default event. Is that possible or is there a hook I can use? Having a default event each day is the problem, otherwise the user is going to have to choose from 122 events!
  
  **Tags:** webform-civicrm, 4.6.8
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-09-27. Score: 4 | Accepted answer
  
  If this is on Drupal, you could generate a View that displays links to the webform and form the link with each event's event id in the URL.
  
  Add a new view of CiviCRM Events.
  
  This will add the event id field. Under settings for that field, check Exclude from Display and make sure for Thousands Marker you change it from comma to none.
  
  Add the start date field.
  
  Add a Global Custom Text field. In the Text area put Register for this Event (or something like that). Under Rewrite results, select output this field as a link. This is where you will link to the webform prefilled with the correct event id. I don't do much work with events, but according to the help on the webform integration:
  
  > Allow events in "User Select" mode to be auto-filled from URL.
  >
  > Example for "Register all":
  > <http://example.com/node/>{node.nid}?event1={event1.event\_id},{event2.event\_id}
  >
  > Example for "Register separately":
  > <http://example.com/node/>{node.nid}?c1event1={event1.event\_id},{event2.event\_id}&c2event1={event3.event\_id}
  
  So your rewrite might be something like node/1?event1=[id] where node/1 is the path to your webform.
  
  On the webform civi settings under event, make sure you have "Allow events to be autoloaded from URL checked."
  
  Then under the view's filter section add start date, change the operator to "Is greater than," in the Value area, change it to An offset from the current time such as "+1 day" or "-2 hours -30 minutes" and in Value field enter Now.
  
  This should give you a view of all upcoming events with a link to the webform prefilled with the correct event.
  
  You'd need to add some more filters to get just what you need and add a sort by start date, but this should get you in the ball park.
  
  > **Comments:**
  > **username_0**: It is Drupal - can you explain a bit more how Views could generate a default event- I guess based on today's date?  
  > **username_1**: Added detail to answer.  
  > **username_0**: Thanks for this very detailed explanation - almost there with this!  
  > **username_0**: Terrific - worked 100%.  Thank you so much!  I have not used Views much but obviously it's very useful stuff to know.  
  > **username_1**: Glad it worked.  
  > **username_0**: I had this working on a test site (it still does) but cannot get it working on a live site.  I can see that the events code works as it shows me the events correctly selected, but the webform shows nothing selected ( - None - ). I can't see any differences between the sites (views & webform same release level) but there must be something.  How is the link made between the view and the webform? If I could understand that maybe I could figure out what's wrong - as that seem to be the problem.  Thanks for your help!  
  > **username_1**: Just an idea. Hover over the link and see if the event id has a comma in it.  If it does, edit the view and make sure that the thousands marker is set to none.  
  > **username_0**: Forgive my ignorance (& thanks for the quick response) but which link?  I did set the thousands marker to none for the event id field.  The link I have in the global custom text field is 'node/27?event1={event1.event_id},{event2.event_id}'   I tried an absolute url but no difference. I feel pretty sure that views is working fine, for some reason webform isn't picking it up.  But I don't understand how they talk to each other so hard to know what to do next.  
  > **username_1**: I believe the link should be node/27?event1=[id].  
  > **username_1**: By the link, I meant the one generated by the view.  Views basically pre-fills the webform by telling it fill out this web form (in your case node/27) with this event (event id).  [id] is the token in the view that specifies which event you're referring to.  
  > **username_0**: Thanks for the explanation - I tried the link you suggested but again webform didn't use it. In fact I saw that link in Views by hovering over the link for the first selected event - the url was https://www.dcm-admin.org.uk/node/25?event1=163#overlay-context=civicrm/admin/setting/updateConfigBackend%3Freset%3D1 and if you click on  that link it takes you to the webform with that event selected. I'm wondering if a bug had crept into the latest webform modules as this was working...  
  > **username_1**: View is formed correctly then it must be webform related.  Are you sure Allow events to be autoloaded from URL is checked.  
  > **username_0**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/32243/discussion-between-andy-clark-and-paul-mosey).  
  
  ---
  
  