the goal:
-show the remainder of the current month's events always
-when end of month is near (after the 18th, for example), also show the upcoming month's events

this is what i have presently, which works:

{if {current_time format="%d"} > 18}  
  {exp:calendar:cal calendar_id="5057" date_range_start="today" show_months="2" pad_short_weeks="n"}
  {exp:calendar:cal calendar_id="5057" date_range_start="today" show_months="1" pad_short_weeks="n"}

however, it's not terribly efficient, when all i really want to do is toggle the show_months="1" to "2" -- and the template doesn't like that i have two opened {exp} and only one closed {/exp}

thought i could get away with:

show_months="{if {current_time format="%d"} > 18}2{if:else}1{/if}"

but that just fails silently. any tips?


This doesn't works because this conditional isn't a simple one, so the template parser tries to parse the exp:calendar:cal before the conditional.

Simple conditionals looks like this:

{if foo == "bar"}

They are parsed before at the stage 13 on Rendering stages.

Everything else are advanced conditionals, parsed at stage 18.

So, {if {current_time format="%d"} > 18}[...]{if:else}[...]{/if} and {if {current_time format="%d"} > "18"}[...]{/if} {if {current_time format="%d"} < "19"}[...]{/if} looks like the same, but, for the EECMS template engine, they aren't.

Please, try this:

{exp:calendar:cal calendar_id="5057"
    {if {current_time format="%d"} > "18"}  
    {if {current_time format="%d"} < "19"}  

I never tried to use a string after a >, but I can't test now. Please, test.

Take a look at the EECMS parsing order to understand better what is happening.

  • I gonna update my answer.
    – Sobral
    Jan 2 '14 at 17:28
  • i really appreciate the continued attempts, but this only outputs a show_months="1" no matter what numbers i input in the variables. i even tried using %j to show a single digit number without the leading 0 that %d uses. but it's no use. Jan 6 '14 at 18:13
  • Please, try using formta="%j" and 18, instead of "18".
    – Sobral
    Jan 6 '14 at 22:11
  • i tried it with and without quotes, with %d and %j, with and without the if:else. it always chooses the latter variable, no matter what numbers i enter. (ie: testing with 1 instead of 18 to try and force the first variable.) Jan 7 '14 at 22:47
  • so frustrating. i tried to do this with PHP instead, thinking i could avoid the EE conditional altogether. {exp:calendar:cal calendar_id="5057" date_range_start="today" <?php $today = date('j'); if ($today > 18) { // if later in the month, show next month as well ?> show_months="2" <?php } else { // show the rest of this month only ?> show_months="1" <?php } ?> pad_short_weeks="n" } this always produces the the 2nd option, no matter the variables. if i run the same conditional and put the full {embed} code instead, i get the opposite. Jan 15 '14 at 20:22

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.