Conditional Help

Hi there. We want to add a conditional to the upcoming_events variable but I’m not seeing any matching variables for it in the documentation. We want to show upcoming events at the top of lists but ONLY for featured events for that particular day or “today”. This code is currently in lw_cal_day.html. It adds upcoming events but for that entire week, not just the day.

{[ if (obj.upcoming_events) { ]}
<div class="upcoming-events">
    <h2>Upcoming Featured Events</h2>
    <ul class="lw_cal_event_list">
        {{ upcoming_events }}
    </ul>
</div>
{[ } ]}

We want to show featured events for just that day. So something like…

{[ if (obj.upcoming_events ***(for just this day)***) { ]}
<div class="upcoming-events">
    <h2>Upcoming Featured Events</h2>
    <ul class="lw_cal_event_list">
        {{ upcoming_events ***(for just this day)***) }} 
    </ul>
</div>
{[ } ]}

If this is possible, please let me know how to go about it.

Thanks as always!
Adam

Hi Adam,

Thanks – we don’t have any built-in ways to modify that particular upcoming_events variable, but folks often do things like this by adding a widget to the top of their calendar theming.

The widget would show the same results on every view, though, so if you just wanted “Today’s Featured Events” say, you could add that to lw_cal_day.html, and then maybe hide it with CSS or JS when you navigate off of the Today view.

Or, you can use the existing CSS classes to style featured events differently in day/week/all views even as they appear “in-line” with the other events of the day.

Otherwise, to separate out each day’s starred events is possible but would involve a bit of deeper customization to your calendar. Happy to quote something out if you wanted to reach out via the Request Help Form; hope this helps!

Karl