4

I am trying to use recurring dates for one of my content types (Event) to limit the amount of Event records.

I would like to have one Event record created for all dates of that Event. For example if an Event occurs every week for a year I have 1 record instead of 52.

Still I would like to see 52 separate lines in the related View because I would like to be able to sort/filter the View to see current week's Events only.

How to set up a Events View for that data so that each view line shows one date only ?

I would like a View to return a list like this...

 - Event A  12-10-2011 
 - Event B  12-11-2011
 - Event A  12-12-2011
 - Event B  12-13-2011 
 - Event A  12-14-2011 
 - Event B  12-15-2011

(Event A and B are recurring every second day )

...instead of a list like this:

 - Event A  
    - 12-10-2011
    - 12-12-2011
    - 12-14-2011
 - Event B 
    - 12-11-2011
    - 12-13-2011
    - 12-15-2011
 - Event A  
    - 12-10-2011
    - 12-12-2011
    - 12-14-2011
 - Event B 
    - 12-11-2011
    - 12-13-2011
    - 12-15-2011
 - Event A  
    - 12-10-2011
    - 12-12-2011
    - 12-14-2011
 - Event B 
    - 12-11-2011
    - 12-13-2011
    - 12-15-2011
1
  • Please note I know how to do it without recurring dates but I specifically need to limit the amount of data to be stored in and especially entered into the database. That is why I would prefer to use recurring dates or another simillar solution.
    – LLub
    Commented Dec 8, 2011 at 11:59

3 Answers 3

5

Eventually I found how to set this up an easy way:

  1. Go to your View

  2. Go to Displays --> <your display name, for example Page> --> Edit

  3. Select Format : Table

  4. Add a date field:

  5. Select a Content: <your date field name>

  6. You will see Configure field: Content: <your date field name>

  7. Go to "Multiple field settings"

  8. Uncheck "Display all values in the same row"

If checked, multiple values for this field will be shown in the same row. If not checked, each value in this field will create a new row. If using group by, please make sure to group by "Entity ID" for this setting to have any effect.

0

You can also use "unformatted list" and filter your dates with "greater than or equal" now to show current and upcoming events.

0

If you use Display Suite for displaying the events (Show: Display Suite) you can do something like this in a custom module. Remember to change 'mymodule' and 'field_date' to correspond your module and date field names.

/**
 * Implements hook_ds_views_row_render_entity_alter()
 */
function mymodule_ds_views_row_render_entity_alter(&$content, &$context) {
  //Display only the current date value from repeating dates
  $date_field_name = 'field_date';
  if (isset($content[$date_field_name]) && count($content[$date_field_name]['#items']) > 1) {
    // Modify the view, or the content render array in the context of a view.
    for ($i = 0; $i < count($content[$date_field_name]['#items']); ++$i) {
      if($content[$date_field_name]['#items'][$i]['value'] != $context['row']->field_data_field_date_field_date_value) {
        unset($content[$date_field_name][$i]);
      }
    }
  }
}

If you are just using fields as your Show option you can probably do something similar with View's hooks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.