Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I'm working on a calendar which shows availability of travel promotions. I would like to mark certain dates as holidays (it's a good time for travel). E.g. I would like to put Christmas tree icon on December 24, 25 and 26th. I would like it to show on all calendars I have on my web page, so I guess it should be set either in CSS file or in module code. Concerning CSS I guess there is no class for particular date, only for set status (available, booked etc.).
Any ideas how to approach this?
migajos
Comments
Comment #2
fietserwinFor now it is indeed hard/impossible to select specific dates yourself using CSS only. However with a bit of jQuery you can do the following (untested, but it should work):
$(".cal-month[data-cal-month=12] tbody > tr > td > span").contains("25").addClass("christmas")
In PHP you could generate such a string for any given date (again untested, not even syntax checked):
HTH, please close this issue if this solves the problem for you.
Comment #3
migajos CreditAttribution: migajos commentedLooks like a solution :). Thank You very much. I will test and work on those options.
Comment #4
migajos CreditAttribution: migajos commentedComment #6
migajos CreditAttribution: migajos commentedFietserwin, sorry for asking probably a stupid question, but I would like to try to implement this without a developers help.
Where do I put this code?
$myYear = 2017;
$myMonth = 7;
$myDay = 14;
$myClass = 'quatorze-juillet';
$js = "$(\".cal-month[data-cal-year=$myYear][data-cal-month=$myMonth] tbody > tr > td > span\").contains(\"$myDay\").addClass(\"$myClass\")";
drupal_add_js($js);
Should I create a new php file? Or should I place it in some existing file of a module?
thx
migajos
Comment #7
fietserwinNever place it in an existing module file. Create a custom module or theme. In both cases you can create a hook_preprocess_HOOK function that contains this code, the HOOK being availability_calendar, hook being your custom module or theme name.
Comment #8
migajos CreditAttribution: migajos commentedSo if I name my custom module "availability_calendar_special_dates", would the PHP file inside look like this?
Comment #9
fietserwinYes, correct.
Comment #10
migajos CreditAttribution: migajos commentedThank You.
Great module btw. Really well maintained.
Comment #11
migajos CreditAttribution: migajos commentedUnfortunately I can not make it work.
The module seems to be installed properly. I've activated it on admin/modules page. The module consists two files:
availability_calendars_special_dates.info
and
availability_calendars_special_dates.module
I've added to my CSS file:
The December 24th 2017 doesn't get black background. Am I missing something?