I was thinking about automating "New" icon display for article that I am adding to my site. Currently, my production site is non-modx and relatively static, so I simply append the "new.png" at the end of the list item that is new, and remove the icon after a month or so.
My Prototype site uses modx and also I use getresources to automatically generate the list page. So inside me thinks using the modification date that is available for each resources, I should be able to conditionally add the icon to list items and automate that part. I am thinking something like;
if today minus modification date is less than 30 days, then show new.png
It is much appreciated if somebody can direct me as to where to start and general idea of how this can be done using modx utilities. I am comfortable with CSS and javaScript but have still learning PHP (and modx), by the way.
One common way is to put a placeholder on the page for the whole image tag, then set that in your snippet, something like this:
/* snippet code */
// set $isNew here
if ($isNew) {
$ph = 'img src="' . $imagePath . '" alt = "something" />'
} else {
$ph = '';
}
$modx->setPlaceholder('NewImage',$ph);