onjegolders
onjegolders

Reputation: 1059

Expressionengine conditionals

am having trouble with a conditional in EE

In an events channel, there's a field for excerpt, after_event_excerpt as well as start_date and end_date

I basically want to show the after_event_excerpt if

  1. There is an after_event_excerpt (field not compulsory)

    AND

  2. Either the start_date > current_time OR start_date AND end_date > current_time (as end_date is not a compulsory field)

I came up with this, but the page won't load due to errors..

{if event_after_excerpt AND event_start_date > current_time || event_start_date > current_time AND event_end_date > current_time}}

            <p class="event_description">{event_after_excerpt}</p>

            {if:else}

            <p class="event_description">{event_excerpt}</p>

            {/if}

Would appreciate any help, thanks

Upvotes: 0

Views: 3423

Answers (1)

Derek Hogue
Derek Hogue

Reputation: 4564

Don't you want to show the {event_after_excerpt} if the event is in the past, not the future? I'm going to operate on that assumption.

{if event_after_excerpt AND event_start_date < current_time AND event_end_date < current_time}
    <p class="event_description">{event_after_excerpt}</p>
{if:else}
    <p class="event_description">{event_excerpt}</p>
{/if}

So, if you have something in {event_after_excerpt}, and the event starts in the past, and it ends in the past (an empty end date will be equivalent to 0, so it's always in the past), then show {event_after_excerpt}.

Upvotes: 2

Related Questions