Show modal/popup on a certain date?

Hello,
is it possible to show a modal or popup on a certain date?
I want to show a message on the Dutch holiday’s date’s
I tried mxcalendar and play with resource Publish Date function but no success

Stefan

Yep should be possible. You’ll need to create a snippet with something like this in it (untested) and a chunk for your modal.

$today = date("d/m/Y"); 
$holiday = '05/12/2017';

if ($today === $holiday) {
   	$output = $modx->getChunk('modal_chunk');
   	return $output;
}

Then just call the snippet on the page or template you want to display it on. If you want multiple holidays then you could transform the snippet above into a switch case.

@lkfranklin
Thanks your (and my first) snippet works great. And i will find out how the “switch case” works

Stil have a question. How to trigger the modal?

The snippet calls the chunk(that work fine) but how to trigger the modal?

Triggering the modal is not related to modx specifically.

You can use whatever client-side solution that best fits your needs.

If the chunk only renders if the date matches then you could have it as display:block in your css by default, or maybe add a class to force display: block.

If you want it to be triggered by a button then you could give the modal an id and then use JS to show/hide the modal.

I just uploaded a video yesterday where I did something similar, check it out here at this time stamp:

Thanks for the help. Its works perfect!!!
Edit:

If someone wants to help me to transform the snippet to a switch case for multiple holiday’s?
I am grateful for that
Stefan

Please see: https://www.w3schools.com/php/php_switch.asp

So something like this I think:

switch ($date) {
    case "01-01-2019":
        // render chunk
        break;

    case "01-02-2019":
        // render chunk
        break;
};

Maybe an array is easier?

$today = date("d/m/Y"); 
$holidays = array(
	"01-01-2019" => 'Holiday name here',
	"01-02-2019" => 'Holiday name here',
	"01-03-2019" => 'Holiday name here'
);

if( array_key_exists( $today, $holidays ) ){
 // render chunk
}

(code = untested)