Creating time-dependent Content

Community Manager
Community Manager
2 0 515

Sometimes it is necessary to create pages, which change their content automatically from one day to another (examples: advent calendar, news, releases, events).

But also if you configured the validity period of your templates or your datasets in a correct way, it is possible just your content didn't change at the "change-date", while everything else is up to date.

Why that?


FirstSpirit always generates the status of the last modification. If you edit you content by hand, most often it is also the time you deploy it. So the edit- and deployment-moment are nearly at the same time. But between the end of your validity period and the moment of the last modification could be hours (or days).

So if somebody edits anything within the project at day x in the afternoon and your content should change at 2 am one day later (x+1), then the point of the last modification is at day x in the afternoon. At this moment your content had the old status and it still has at the next day.

Well then?


Change the point of the last modification to "now" before the generate-process starts. Of course nobody can edit the content by hand in the middle of the night. (Well, if you're a nighthawk, you can, but in general most people sleep at 2 am). So use a script!

Where? Let me tell you...

1.) Open the "Server and Project Configuration"

2.) Open the "Projectsettings" and find the correct "Schedule entry" for your content within the "Schedule management"

3.) Add a script before the (first) generate-action

4.) Add the following lines inside the script

context.getProject().createTag("Generation","needed for external database content",null);

context.setStartTime(new Date());


The first line creates a new revision, which is equivalent to an edit by hand.

The second line changes the moment of the last modification to now.


It is quite simple, if you know the "How to".