Publish resource on specific days of the week

I am looking for a way to publish a resource (or perhaps other sort of content) for only weekdays, not in the weekend. Is there a way to do this, without any PHP programming?

When you edit a ressource, in the “Settings” tab, you will find a “publish date” field (see image)

Could you use this ? If not, the only solution I see would be to write a plugin, which nvolves PHP programming…

I don’t know of any existing Modx Extra doing this, but I might be wrong

If you mean that you want the resource set to unpublished every weekend then reset to published every Monday, that’s fairly difficult. It would mean setting up a cron job that ran every night at midnight, checked to see if the new day was a weekday or weekend day, and set the published status of the resource accordingly with a custom snippet. It could be done, but not without some programming.

It would be easier if you could leave the resource published, but show different content on it depending on whether the current day was a weekday or weekend day. That could be done with a fairly simple snippet.

Thanks. Different content would also be fine. But snippets are not my thing.

Wouldn’t it work with TV’s based on day of the week?

I’m not sure what that means, unless the TV contains PHP code, in which case it would be more efficient to use a snippet. Otherwise, a TV has no way of knowing what day of the week it is.

The snippet would be fairly simple. This should work if you create two chunks called weekdayChunk and weekendChunk to hold the content and used their names for the property values in this tag on the page in the spot where you want the content to appear:

[[!DayCheck? &weekendChunk=`weekendChunk` &weekdayChunk=`weekDayChunk`]] 

Then create a snippet called DayCheck and paste in this code:

<?php
/* DayCheck Snippet */

/* Get chunk names from tag */
$weekdayChunk = $modx->getOption('weekdayChunk', $scriptProperties);
$weekendChunk = $modx->getOption('weekendChunk', $scriptProperties);

if ((date('N', time()) >= 6)) {
     $chunk = $weekendChunk;
} else {
    $chunk = $weekdayChunk;
}

/* Get the appropriate chunk and return it */
return $modx->getChunk($chunk);

I should mention that different countries start the week on different days and some countries have a different definition of “weekend,” so this would be somewhat limited.

The switchover will be at midnight, but that’s typically midnight where the server is.