is it possible to restrict de display of months to only the current year? (so in januari show all 12 months, november show last 2, etc )?

Comments

fietserwin’s picture

Status: Active » Postponed

What you can do is implement this theme preprocess hook:

function mymodule_preprocess_availability_calendar_months(&$variables) {
  $months_until_end_of_year = ...;
  $variables['settings']['show_number_of_months'] = $months_until_end_of_year;
}

Make sure that you don't increase this setting OR that you execute before availability_calendar's own theme preprocess hook, as this hook reads the availability from the database and if it reads to few, behaviour will be undefined. You can assure so by implementing these lines of code into the preprocess functions for both theme availability_calendar and theme availability_calendar_viewport.

I'll leave this request open for now as I might implement it in the future.

fietserwin’s picture

Version: 7.x-3.x-dev » 7.x-4.x-dev
daskog’s picture

What file do i edit..? and a little before after snippet would help me understand the implementation.

Thanks in advance.

daskog’s picture

Issue summary: View changes

Anyone?

fietserwin’s picture

Create a custom module to implement the theme preprocess as above. I leave the date arithmetic up to you.

daskog’s picture

<?php
function year_view_preprocess_availability_calendar_months(&$variables) {
  $months_until_end_of_year = 13 - date('n'); // Month without leading zero
  $variables['settings']['show_number_of_months'] = $months_until_end_of_year;
}

Let me start with saying thank you for your feedback.

This works, but how to set the starting month to January, how would the actual string on numbers look like?

fietserwin’s picture

Showing past dates is a different issue, though probably a bit related. You can set the start year and month via the similarly named variables, but that will still show all past dates as "past dates" thus hiding the actual availability.

There is another issue to show past dates : #1490928: Showing dates in the past.

If you just want to continue, you can override this module's theme function. See e.g.: https://drupal.org/node/1621416. Patches are welcome though for the other issue.