Creating time-dependent Content

MichaelaReydt
Community Manager
Community Manager
3 0 1,244

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?

Explanation

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?

Solution

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());

Script-Explanation

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.

Conclusion

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

Version history
Last update:
‎09-13-2011 12:14 AM
Updated by: