0

I'm trying to setup a conditional to only show the Start Date when the Start Date and End Date match, but I can't get it to work in Matrix and I can't find a similar question anywhere.

Here's what I have so far. I'm using the Time Select fieldtype add-on.

{exp:channel:entries entry_id="8" dynamic="off"}
    {sessions}
        {if "{start_date format='%M %j'}" == "{end_date format='%M %j'}"}
            <li>{start_date format="%M %j"}</li>
        {if:else}
            <li>{start_date format="%M %j"} - {end_date format="%M %j"}</li>
        {/if}
    {/sessions}
{/exp:channel:entries}
1

EECMS saves dates as UNIX timestamps. You don't need to format the fields just to compare each other.

I don't know if Time Select uses something different, but it worth a try.

{exp:channel:entries entry_id="8" dynamic="off"}
    {sessions}
            <li>
               {start_date format="%M %j"}
               {if start_date != end_date} - {end_date format="%M %j"}{/if}
            </li>
        {/if}
    {/sessions}
{/exp:channel:entries}
| improve this answer | |
0

Try to remove the the quotation marks:

  {if "start_date format='%M %j'" == "{end_date format='%M %j'}"}

Sometimes it needs to remove them with conditional.

| improve this answer | |

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.