Events list - advance dates
11 posts by 3 authors in: Forums > CMS Builder
Last Post: June 10 (RSS)
By MercerDesign - May 15
I have a live stream function, so events are put into a list with a publishDate and removeDate, these have to be put in manually each week. Is there a way we can have an 'advance a week' button. This would advance every livestream event on by seven calendar days. This would reduce the need to manually advance each event (for both its start time and end time).
Thank you in advance.
Hi MercerDesign,
Yea, you could make a plugin for that.
So you want to advance the publishDate and removeDate by a week for ALL the records in a section? Is that right?
And why do you need to do that? I'm wondering if there's a simpler solution.
Thanks!
interactivetools.com
By MercerDesign - May 16
Hi Dave
So you want to advance the publishDate and removeDate by a week for ALL the records in a section? Is that right? Yes please.
And why do you need to do that? I'm wondering if there's a simpler solution. So my client doesn't have to go into each record in that section and manually change the date each week.
Hi MercerDesign,
Can you help me understand why they're updating those dates at all? You have livestreams that repeat weekly and you want them shown at some times but not other times? I'm just wondering if publish/removeDate is the best way to accomplish that. Can you tell me more?
interactivetools.com
By MercerDesign - May 19
They have files that are linked to the events, so they only want the file visible when each LiveStream is scheduled, so the Publish and Remove is timed to when the LiveStream is showing.
Hi MercerDesign,
Be sure to backup your database first, then you could try a script like this:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
// load viewer library
$libraryPath = 'cmsb/lib/viewer_functions.php';
$dirsToCheck = ['','../','../../','../../../','../../../../'];
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// Increment dates by one week
$baseTable = "livestreams"; // don't include table prefix
$fields = ['publishDate', 'removeDate'];
// Move date fields forward 7 days when date is defined
foreach ($fields as $field) {
$query = "UPDATE `:table`
SET `:field` = DATE_ADD(`:field`, INTERVAL :increment WEEK)
WHERE `:field` != :zeroDate AND `:field` IS NOT NULL";
DB::query($query, [
':table' => DB::getFullTable($baseTable), // adds prefix if needed
':field' => $field,
':increment' => 1,
':zeroDate' => "0000-00-00 00:00:00",
]);
}
echo "All publish and remove dates have been incremented by one week.\n";
And then, if that works, add a link to it somewhere convenient in the CMS. Note that you might need to update the "Load viewer library" code to match your server.
Hope that helps!
interactivetools.com
Also, for anyone wanting to understand more about PHP, MySQL, or ZenDB (our database library). If you go to chatgpt.com and select the o3 model, just paste in this query and it will explain it to you and answer any questions:
Here's some code that uses https://github.com/interactivetools-com/ZenDB/
Can you explain it to me step by step.[COPY/PASTE CODE HERE]
interactivetools.com
By MercerDesign - June 4
This is all working (thank you) but is it possible for the 'push dates on a week' function to erase all files that have been loaded up for each event, they are pdfs loaded up to a 'documents' upload area.
I am wondering if simply utilizing the "hidden" field would be useful? I tell my clients that if they hide a record then it stays in the database but doesn't show to the public. This way if they have specials, information, docs, etc. that may be utilized again in the future it's a lot easier and faster to just unhide and update. Example: every October they have a fall harvest event and most of the vendors, sponsors (along with their logos, pdfs, etc.) are the same so instead of rebuilding the listing from scratch each year they just unhide and update.
For some other clients I create replicas of certain sections and add an "Archive" field. Any record with "archive" checked stops showing in the current publicly viewable records and then appears in archived publicly viewable records. For them it allows any pages previously built and captured by search engines to be retained but doesn't overload their gallery or available listings. Example: Classic Car For Sale Gallery. At any given time the business has 75 cars available, but have sold hundreds and thousands. That's a lot of searchable and indexed data to just dump. The business wants to keep the data out there but doesn't want their car for sale listings to be overrun by old sold car listings. So this is a win for the business and their prospective customers.