3

I have an event content type that has a date field (the time the event will take place)

I like to list these events and have them grouped by Day / Week / Month
I dislike the calendar layout, it is too messy

Any ideas are welcome

I attached this mockup of what i'm looking for. The person interested in the event's section should be able to filter the events by day/week/month

Events filtering by day, week, month

Extra question : Would it be possible to have a 'next weekend' filter (relative to the time the person is visiting the website) ?

1 Answer 1

1

What you need to do is create a custom PHP field and manually code out the group by conditions as you have set there. I had the same issue I documented on my blog here: http://drupul.com/content/views-multiple-group-recipe-drupal-7

This is the code I used in my PHP field:

<?php 
global $prev_month;
global $month;

if($prev_month != date('F Y', strtotime($data->field_field_date_2[0]['raw']['value'])))
{ 
  $month = '<h4>'. date('F Y', strtotime($data->field_field_date_2[0]['raw']['value'])) .'</h4>'; 
  $prev_month = date('F Y', strtotime($data->field_field_date_2[0]['raw']['value'])); 
} 
else 
{ $month = ''; }

print($month .'<h5>'. date('M d', strtotime($data->field_field_date_2[0]['raw']['value'])) .'</h5>');
?>

You will of course have to modify it to your setup, but its very similar to the setup you need as I needed it to be grouped by month then week and then day.

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.