I’m currently building/rebuilding a church website. I have a decent understanding of EE and how it works. My question: I need to make a date field repeat weekly but am not sure if this is possible. I have managed to get far enough to have a channel for this that can be edited manually during development: the json code I am currently using is below
{exp:channel:entries channel="countdown" orderby="date" sort="desc" show_future_entries="no" limit="1"}
{"meta": {"status": 200 }, "response": {"item": {"isLive": false, "eventStartTime": "{event_start_time format="%Y-%m-%d %g:%i:%s"}" }}}
{/exp:channel:entries}
If this requires a paid add-on that is currently not an option.
Thanks Rob unfortunately that is not an option. It is a great plugin though.
I did have a thought but not sure if it can be converted to EE code. On an old website I did using Rock RMS I was able to create a webrequest that could pull from an existing api. The code from that can be found on Github:
This allowed for the data to be cached in the database for Rock saving the need for constant requests to the api
Andy this is for a countdown. I’m trying to automate the json data to repopulate for the same time/day each week (Sunday at 10am MST). the output example
{ "meta": { "status": 200 }, "response": { "item": { "isLive": false, "eventStartTime": "2022-03-06 10:00:00" } } }
Currently I’m using a content channel but that requires manually editing. My template code is on github if you’re willing to take a look
When do you want this to update to the next date. For example if it currently returns 2022-03-06 10:00:00
then when would you want it to return 2022-03-13 10:00:00
?
I would probably just write an add-on that uses either a text file or database table to store the last date. Then check that date compared to the current time. if the difference is X then update to show the next Sunday’s time and update the time stamp in your text file or database.
While ExpressionEngine doesn’t offer built-in functionality to automatically repeat dates in channels, here are a couple of approaches you can consider without paid add-ons:
1. Manual Updates:
This approach is best for a limited number of repeating events. You can manually create entries with the desired dates throughout the week. This might be suitable for a small church calendar with few recurring events.
2. Template Logic with a Scheduled Task:
This method involves more technical steps but automates date updates:
Template Logic:
{event_start_time}
, create a conditional statement that checks if the date is within the current week.Scheduled Task:
event_start_time
field in your channel entries for the following week. You can achieve this using the ExpressionEngine Channel API or a custom script interacting with your database.Here’s a basic outline of the script logic:
php
// Get the current date and calculate the beginning of the next week
$today = new DateTime();
$nextWeekStart = $today->modify('next sunday');
// Fetch existing entries for the "countdown" channel
$entries = // Fetch entries using Channel API
// Loop through entries and update dates for next week
foreach ($entries as $entry) {
$newDate = $entry->event_start_time->add(new DateInterval('P7D')); // Add 7 days
if ($newDate >= $nextWeekStart) {
// Update the entry's event_start_time with the new date
$entry->update(array('event_start_time' => $newDate));
}
}
Remember:
If these approaches seem too complex, you might explore community Geometry Dash forums or consult ExpressionEngine development resources for alternative solutions or potential free add-ons that might align with your requirements.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.