Time-based swapping of content

Hello,

I have course content that I’d like to feed out over anywhere between 7 and 90 days.

I’m trying to figure out the best way to trigger swapping the content for each day of the course.

Database:

  • I have a Thing for each day’s content, with fields for: 1) content, 2)course the content is for and 3) which day of the course.
  • When a user starts a course a Thing is created for their order that includes a start timestamp.

Interface:

  • The page that displays the content has a custom state for the day the user is currently on in the course. The days are pulled from an Option Set in the database from 0-90.
  • The text fields search for the appropriate content based on the page state’s indicated day.

Workflow (this is where I think I’m making this way too complicated)

  • When a user selects the course they want, the workflow checks their start timestamp for that course, then calculates the number of hours from that time to present, turns it into a day and sets the page’s state to that day (see screenshot). This was fine when courses were only 7 days long. Now they’re moving on to 90 days and it seems ridiculous to have 90 steps in the workflow to calculate the day. I know there’s a better way to do this, but not sure what it is.

Any guidance would be greatly appreciated!
Thank you

This is not the only way to do this, but you could store a day number field (number type) in the course table. When the page is loaded, you can calculate the no of days that have passed since then > Current date/time - Course start date: format as days:floor

You can search for the course with this day number and show the content.

Himanshu
Bubble tutorials

1 Like

@sharma.himanshu0608, that worked beautifully! Thank you!

This topic was automatically closed after 70 days. New replies are no longer allowed.