Show future dates only in CMS section
3 posts by 2 authors in: Forums > CMS Builder
Last Post: 3 hours ago (RSS)
By Dave - Yesterday at 2:34pm
Hi celuch,
There's no built-in way to permanently hide past records from the editor list. That one needs a small custom plugin (or code change).
Try saving this in your /plugins/ folder as futureDatesOnly.php (or something similar):
<?php
/*
Plugin Name: Future Dates Only
Description: Hides past-dated records from a section's editor list, so users only see upcoming records.
Version: 1.00
*/
use Itools\Cmsb\Plugin;
Plugin::on('list_where', function (string $where, string $table): string {
$forTable = 'events';
$dateField = 'event_date';
if ($table === $forTable) {
$where = "($where) AND `$dateField` >= CURDATE()";
}
return $where;
});
Just change $forTable and $dateField to match your table and field.
Hope that helps, let me know any questions.
Thanks!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com