Re: Re: [Jason] Can removeDate be optional?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 13, 2019   (RSS)

In response to: https://www.interactivetools.com/forum/forum-posts.php?postNum=2208349#post2208349

I've got an existing section that has a lot of records in it.  A new requirement on the site is to have some items publish and remove at a certain time. 

publishDate as "blank" and everything is published after 0000-00-00 00:00:00

removeDate as "blank" means everything is not published as everything is after 0000-00-00 00:00:00

There are a number of work arounds, but wouldn't it be better to change the CMSB base code to say if "blank" then ignore, or make blank removeDate 9999-99-99 99:99:99 to get the reverse action as the publishDate?

Cheers,

Tim (toledoh.com.au)

Hey Tim,

I agree that having a blank remove date be "ignored" is the more intuitive (and potentially useful) behaviour, however, this sort of change needs to be carefully considered as it may not be backwards-compatible. I'll flag this topic for internal discussion.

Thanks!

Daniel
Technical Lead
interactivetools.com

Hi Tim,

We've elected to make this change and include it in the next version of CMSB. If you'd like to apply the functionality before then, it's fairly simple to patch.

In /cmsb/lib/viewer_functions.php, find the following line (Line 1309 in CMSB 3.53):

$thisCondition  = "{$tableNameDot}removeDate >= NOW()";  // NULL end date or future end date

And replace it with this:

$thisCondition  = "({$tableNameDot}removeDate >= NOW() || {$tableNameDot}removeDate = '0000-00-00 00:00:00')";  // NULL end date or future end date

Note that this patch hasn't gone through final review yet, so use at your own caution.

As well, since I didn't see it mentioned in the previous thread, I feel it's worth noting that there's another special field called "neverRemove" - this field can be added as a checkbox to a section to ignore the removeDate on a per-record basis. This could be useful in some cases where it's not possible to upgrade or patch.

Let me know any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com