I have a Matrix block weeklyMenuItems
, each item in the block has a dropdown with days of the week (Monday, Tuesday etc). Each entry will have a Matrix block with 7 items, matching the 7 days of the week.
In the template, I would like to start the loop from todays day but still include previous days in the loop, at the end. So, according to the example, whichever item.dayOfTheWeek
matches {{ now|date('l') }}
.
For instance, if today's day is Wednesday, the loop will output...
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
- Monday
- Tuesday
Here is part of my code, the entries that are being looped are from an entries field of another channel menuSection
but I don't think that matters in this instance.
{% for entry in craft.entries.section('menuSection').find() %}
{% for menuItem in entry.menuEntries %}
<h2>{{ menuItem.title }}</h2>
<ul>
{# Matrix blocks #}
{% for item in menuItem.weeklyMenuItems %}
<li>
<h3>{{ item.dayOfTheWeek }}</h3>
<p>{{ item.itemTitle }}</p>
</li>
{% endfor %}
</ul>
{% endfor %}
{% endfor %}
Any guidance will be welcomed, let me know if I can clarify anything!
Thanks