Nathan Pitmanhello, my name is
nathan pitman.

Hide template based content until a specified date in ExpressionEngine Jul 14. 11

Sometimes it’s desirable to hide content on your website from users a specified date. With ExpressionEngine we already have built in functionality to do this with weblog/channel entries. If you want to achieve a similar effect for blocks of template code then you can simply combine the conditional and date tags as follows:

{if {current_time format="%Y%m%d">= "20110717"}...{/if}

Initially I thought I might need a plug-in to achieve the desired result but it was great to discover I could do just what I wanted out of the box. :)

Update: As pointed out by Philip there are some issues with this approach so tread carefully people, I’ve only tested this concept in a scenario where the current date falls within the same month/year etc.

Update: As suggested by Philip I’ve updated the code sample above to reverse the date format to Ymd, this ‘should’ prevent any issues as Ymd will always increment whereas dmY will not.

blog comments powered by Disqus