0

Can the exp:cal tag filter events by date AND time? Example: I want to show upcoming events for the week but I want to exclude those that have already passed today.

{exp:calendar:cal date_range_start="today" show_weeks="3" event_limit="6" pad_short_weeks="n"}

Should I be using exp:cal? This is Calendar 1.8.14 on EE 2.11.9 (I know it's old but that's what the client has).

I can use a conditional like {if {event_start_date format="%U"} > {current_time format="%U"}} but then my event_limit parameter gets limited even more. I need the same future total amount each time.

5
  • I can use a conditional like {if {event_start_date format="%U"} > {current_time format="%U"}} but then my event_limit parameter gets limited even more. I need the same future total amount each time.
    – James
    Commented Jun 18, 2018 at 18:26
  • Have you tried EE date formatting? I know the current version of Calendar is supposed to allow regular EE date formatting (meaning you can input a date and time in your date_range_start param): docs.expressionengine.com/v3/templates/…
    – jrothafer
    Commented Jun 19, 2018 at 2:01
  • Tried that @jrothafer, problem is there's nowhere where they show using a time filter, so I'm guessing at it.
    – James
    Commented Jun 20, 2018 at 17:32
  • Trying this: date_range_start="{current_time format="%U"}" but that returns absolutely nothing. This: date_range_start="today @ {current_time format="%G:%i"}" but that includes past events from today. I need to just see future dates and hide today's already passed ones.
    – James
    Commented Jun 20, 2018 at 17:43
  • 1
    Ok I think I got it! Had to use date_range_start="today @ {current_time format="%g:%i %A"}" - it needed this format for some odd reason - using epoch time was not doing anything.
    – James
    Commented Jun 20, 2018 at 18:35

2 Answers 2

0

You should try below code to hide Past events and only shows the events for next 1 week.

{exp:calendar:cal pad_short_weeks="n" date_range_start="today" date_range_end="+1 week"}

If some weeks/days are missing then you can also try with the {current_time} variable available in EE to hide the Past events.

{if '{event_start_date format="%U"}' > '{current_time format="%U"}'} 
    {!--Your event data--}
{/if}
4
  • But then my total results gets post-filtered and my limit are ignored, which leaves me a much smaller record set. I tried this, please read the comments (including mine). Thanks.
    – James
    Commented Jun 19, 2018 at 21:24
  • I assumed that you've tried by limit="3" in {exp:calendar:cal}. Can you explain post-filtered means? Commented Jun 20, 2018 at 6:47
  • The exp:cal tag is filtering based on parameters, so it will produce X number of results. If I then use a conditional statement within the EE loop, the results start with X results and get even further filtered (call that "N"), so could end up with X-N results on the page. I want to see X results, so I have to filter everything at the top (in the loop) and not inside the loop. Hopefully that makes sense.
    – James
    Commented Jun 20, 2018 at 17:30
  • I suggested to use if statement only if you need and in the case of any missing events. Don't take it necessary for ee loop. First try with normal ee loop. After that if you will not get some event than only try ee conditional statements. Commented Jun 20, 2018 at 18:30
0

date_range_start="today @ {current_time format="%g:%i %A"}" did the trick, it wasn't recognizing epoch time in the loop. Thanks @jrothafer for the suggestion to re-look at the date formatting variables.

1
  • Groovy, glad to help. Mark your answer as correct as soon as the stack lets you so others can find the answer to this if they need to!
    – jrothafer
    Commented Jun 21, 2018 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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