2

I am putting together a site full of events. Some events are recurring (monthly, daily, yearly), others are one-time events that can be one hour to sometimes three days long. I would like to call out that they are currently happening, have happened or will be happening. What is the best method to do so?

Looking for the functionality as such:

{exp:calendar:cal event_id="{entry_id}"}
    {if event_is_over}This Event is over{/if}
    {if event_is_happening_now}This Event is Currently Happening{/if}
    {if event_will_happen}This Event Will Happen{/if}
{/exp:calendar:cal}

As an aside, the "event will happen" has a javascript countdown timer. Not critical to the answer, but putting it out there.

1
  • Edited original post to give the full breadth of functionality needed. – Dan Johnson Dec 10 '12 at 23:44
2

Updated my answer to reflect your expanded question.

I tested these conditionals inside both the exp:calendar:cal and exp:calendar:events tags and it works as expected. I did not test it with recurring events, though.

{if {event_end_date format="%U"} < current_time}
    event is over
{/if}

{if event_start_date < current_time AND {event_end_date format="%U"} > current_time}
    happening now
{/if}

{if event_start_date > current_time}
    will happen in the future
{/if}

Not sure why the format parameter was required on event_end_date, but without it the tag wasn't parsed. I tested this with Calendar 1.7.0.

0

I'd just use {exp:calendar:day} unless you need to do some strange formatting. This will grab any event happening on the current day and display it. Solspace has some examples of the use if the day tag in their documentation.

3
  • I am using this as a countdown on each events page. If the event has happened I want to say "event is over", if its going on as we speak "event is happening", and if it is upcoming I want to say "Event is happening in xxdays". – Dan Johnson Dec 10 '12 at 21:39
  • The question wash't posed like this though and Alex's approach wouldn't work either. Perhaps you should pose the question again with this info noted in the edit comments. – Stuart McCoy Dec 10 '12 at 22:43
  • I rephrased the question, I don't see the need to remove it and recreate. Thanks for your answer! – Dan Johnson Dec 10 '12 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.