1

Have an instance where there are two entries - one needs to be shown for six months of the year and the other for the second six months.... looking at a conditional which essentially says:

if date_range = January-June

Show this

If else

Show this

Is it doable with EE's native conditionals or does it need another approach?

5

The following conditional will achieve what you want:

{if {current_time format="%m"} <= 6}
  <p>do Jan through June</p>
{if:else}
  <p>do July through December</p>
{/if}

Edit: Replying to request for March-thru-September date range:

Since the %m flag on the date format represents each month as a number (and conveniently one-based at that), to achieve what you would like you would simply change the code to:

{if {current_time format="%m"} >= 3 && {current_time format="%m"} <= 9}
    <p>do March through September</p>
{if:else}
    <p>do January, February, October, November or December</p>
{/if}
2
  • Is there any way to modify this conditional to a specific range? Say March to September for example?
    – segovius
    Jul 1 '14 at 10:51
  • See revised answer.
    – dashard
    Jul 2 '14 at 4:43

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.