1

I would like to have a calendar be displayed as a filter for a view. When a user clicks on a date on the calendar the views result on this page are updated (preferably via Ajax) to show the chosen dates event. Such as the design below. The calendar should not be a popup calendar.

I am aware of the date popup calendar in views exposed filter options but that only displays the calendar as a popup calendar as expected.

I have tried to look into the calendar module as well, however the default behavior of the mini calendar block does not fit my needs as when the user clicks on a date on the mini calendar it will redirect the user to that specific dates calendar page instead of updating the views listing.

Any suggestions or direction on how to implement such a feature would be greatly appreciated!

Calendar as Exposed Views Filter

1

You can achieve this with calendar module and Date API. The default mini calendar is redirecting to a new page, but you can override it in your template file. I would suggest to use ajax link api module to load your content in a div you would like. You can do something like the following

/**
 * Alters link url in calendar events block in order to filter events at /events
 *
 * @see template_preprocess_calendar_datebox()
 */
function <themeName>_preprocess_calendar_datebox(&$vars) {
  $date = $vars['date'];
  $view = $vars['view'];
  $day_path = calendar_granularity_path($view, 'day');

 //$vars['url'] = 'exhibitions/calendar/' . $date;
  $vars['link'] = !empty($day_path) ? l_ajax($vars['day'], $vars['url'], '#block-system-main') : $vars['day'];
} 

l_ajax function is used to load contents via ajax. Let me know if you need any help.

  • Awesome, thanks! I should be able to work with this now. It seem like the URL changes to the default dates URL like '/calendar-node-field-event-date/day/2015-11-16' Would you know by any chance how to have the URL stay at the current URL as well? – Hershy Nov 16 '15 at 21:34
  • 1
    once you enable ajax link api module, then in configuration you will have an option for not changing the url on ajax load – Shabir A. Nov 16 '15 at 21:36
  • witte.stagetheweb.com/exhibitions/calendar this is one site I have implemented the functionality. – Shabir A. Nov 16 '15 at 21:37

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.