0

We are utilizing a Matrix field to list information by date (each day has it's own row - first column being "date". We want only today's row to be displayed (similar to a calendar). HOWEVER, if an entry containing matrix rows - all of which are outdated, then a note to display "outdated" should appear.

Channel Entry : Department Channel Field : Calendar (Matrix) Columns: Date | Information

For entries that contain an updated monthly calendar, we are correctly identifying and displaying the single row with today's information using this code:

{calendar}
    {if "{date format='%Y%m%d'}" == "{current_time format='%Y%m%d'}"}
        <information here>
    {if}
{/calendar}

BUT, we need it to be a conditional examination of the all of the matrix rows within the entry so that if none of the rows matches current_time, then a notice of "outdated calendar" displays.

Here's the catch - when we have used conditionals like the following, we get repeated display of "outdated" for every row that does not match today.

{calendar}
    {if "{date format='%Y%m%d'}" == "{current_time format='%Y%m%d'}"}
        <information here>
    {if:elseif "{date format='%Y%m%d'}" != "{current_time format='%Y%m%d'}"}
        <"Your calendar is outdated">
    {/if}
{/calendar}

Thus this results in 30 rows of "Your calendar is outdated" - instead of just one.

We ONLY want one item displayed - either today's info (on a row that contains today's date) - OR outdated (if no rows match today's date)

Please help!

1

You can search to see if there are any rows which have a current or future date, then proceed accordingly:

{if '{calendar:total_rows search:date=">={current_time}"}' > 0}
    Your calendar is outdated
{if:else}
    {calendar}
        {if "{date format='%Y%m%d'}" == "{current_time format='%Y%m%d'}"}
            <information here>
        {if}
    {/calendar}
{/if}
| 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.