RSS 2.0
RSS 0.91
ATOM 0.3
January 10, 2007

Making Sure Content Elements Show and Hide at the Proper Time

Category: Ron Hall

By: Ron Hall

When I first started using the show and hide fields, my content elements and pages did not always appear and disappear when I thought they should. Sometimes they would work as expected and sometimes not.

Let's say I edited an element on Tuesday and set it to go live Thursday. If I looked at the page at 8 a.m. Thursday, the element appeared as expected. However, let's say I edited the element at 2 p.m. on Wedensday and set it to go live on Thursday. In this case if I checked it at 8 a.m. Thursday, the element would not appear. I would have to log into the back end and clear the cache in order for the element to appear on the front end.

What was happening? In the second scenerio the cache for the page had not yet expired. It had been less than 24 hours since TYPO3 had last rendered the page (because of my edit the afternoon before). Therefore, the cached version of the page was used. Of course, this was a problem since the reason I used show and hide was so I did not have to get up early each morning to make sure things were on and off the web site as needed.

This is when I discovered a little piece of typoscript that took care of the whole problem.

config.cache_clearAtMidnight = 1

This sets the the cache to expire each night at midnight. Therefore, I could edit a page on Wednesday afternoon, set it to go live on Thursday and as of 12:01 a.m. Thursday it would be live on the site.

This little piece of code is now a standard part of all my site templates.


comment #1
Gravatar: -julle -julle January 10, 2007 19:18
Hi Ron

Actually today, I've been spending some time looking into making the cache dependent on the actual content, thus making TYPO3 able to time content on hours, not only dates. I expect to have a patch ready within a few weeks.

comment #2
Gravatar: Ron Hall Ron Hall January 12, 2007 04:33
That sounds great, Julle. Thanks for the work.

Sorry, comments are closed for this post.