Cant help you there i'm afraid, I had a look to see if i still had the script in my mail but doesnt look like it sorry

class="[[!RecentCheck? &interval=`1 week` &publishedon=`[[+publishedon]]`]]"
<?php
/* RecentCheck snippet */
$output = 'non_recent';
$interval = $modx->getOption('interval', $scriptProperties, '1 week');
$pd = $modx->getOption('publishedon', $scriptProperties, '');
$cutoffTime = strtotime('now - ' . $interval);
if ($cutoffTime === false) {
$output = '[RecentCheck] Invalid interval';
} else {
$ptime = strtotime($pd);
$currentTime = time();
if ($ptime > $cutoffTime) {
/* Yes, it's recent -- Set the return value */
$output = 'recent';
}
}
return $output;I think I wrote a blog post on this, but I can't find it.
Basically, your snippet would send the publishedon or createdon field as a property and the snippet would return the correct class.
This would go in the row Tpl chunk where you want the class to appear:
class="[[!RecentCheck? &interval=`1 week` &publishedon=`[[+publishedon]]`]]"
Here's the snippet code (untested):
<!--?php /* RecentCheck snippet */ $output = 'non_recent'; $interval = $modx--->getOption('interval', $scriptProperties, '1 week'); $pd = $modx->getOption('publishedon', $scriptProperties, ''); $cutoffTime = strtotime('now - ' . $interval); if ($cutoffTime === false) { $output = '[RecentCheck] Invalid interval'; } else { $ptime = strtotime($pd); $currentTime = time(); if ($ptime > $cutoffTime) { /* Yes, it's recent -- Set the return value */ $output = 'recent'; } } return $output;
I think I wrote a blog post on this, but I can't find it.
Basically, your snippet would send the publishedon or createdon field as a property and the snippet would return the correct class.
This would go in the row Tpl chunk where you want the class to appear:
class="[[!RecentCheck? &interval=`1 week` &publishedon=`[[+publishedon]]`]]"
Here's the snippet code (untested):
<!--?php /* RecentCheck snippet */ $output = 'non_recent'; $interval = $modx--->getOption('interval', $scriptProperties, '1 week'); $pd = $modx->getOption('publishedon', $scriptProperties, ''); $cutoffTime = strtotime('now - ' . $interval); if ($cutoffTime === false) { $output = '[RecentCheck] Invalid interval'; } else { $ptime = strtotime($pd); $currentTime = time(); if ($ptime > $cutoffTime) { /* Yes, it's recent -- Set the return value */ $output = 'recent'; } } return $output;
It's part of PHP's strtotime() function, which converts a human-readable date into a Unix timestamp (a huge number of seconds). strtotime() understands lots of interesting text descriptions like "+ 1 week," "-3 months", "now - 2 days", "next thursday," "last friday," etc.