Marking New Entries

When it cam to updating the original version of this script which I wrote back in 2005 I discovered that there was almost nothing of the original script that survived into the new version. This new version of the script takes a completely different approach to attaching "new" images in front of those entries which are less than a specified number of days old.

This new version allows you to create an object that specifies a number of days for which entries are to be considered to be new and the image to display in front of the entries when they are new. The object downloads and caches the image and you then simply call the check() method identifying the id of each entry that may need to be flagged as new specifying the year, month, and day of it being added. Where that date is not more than the specified number of days ago the function will insert a copy of the new image as the first element within the container identified by the id in front of whatever that container previously contained.

To add 'new' images that only appear for a specified number of days you first need to add the following JavaScript to your page.

JavaScript

You can then make use of this object by first defining your own object based on it which specified the number of days and the image to display. Then simply call the check method for each id that may need to include that 'new' image along with the date that the entry was added.

var n = new newDisp(7,'new.gif');
n.check('ent01',2012,8,28);
n.check('ent02',2012,8,24);

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate