-
-
Save pvledoux/6220195 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {exp:stash:set_list name="entries" parse_tags="yes"} | |
| {exp:channel:entries channel="my_channel" orderby="date" sort="desc" dynamic="no" limit="999"} | |
| {stash:title}{title}{/stash:title} | |
| {stash:date_day}{entry_date format="%d"}{/stash:date_day} | |
| {stash:date_month}{entry_date format="%m"}{/stash:date_month} | |
| {stash:date_year}{entry_date format="%Y"}{/stash:date_year} | |
| {stash:date_sort}{entry_date format="%Y-%F"}{/stash:date_sort} | |
| {stash:date_machine}{entry_date}{/stash:date_machine} | |
| {/exp:channel:entries} | |
| {/exp:stash:set_list} | |
| {!-- make a copy containing only the years, so we can find all unique years--} | |
| {exp:stash:set_list name="years" parse_tags="yes"} | |
| {exp:stash:get_list name="entries"} | |
| {stash:date_year}{date_year}{/stash:date_year} | |
| {/exp:stash:get_list} | |
| {/exp:stash:set_list} | |
| {!-- make list of months in reverse order --} | |
| {exp:stash:set_list name="months"} | |
| {stash:month}December{/stash:month} | |
| {stash:month}November{/stash:month} | |
| {stash:month}October{/stash:month} | |
| {stash:month}September{/stash:month} | |
| {stash:month}August{/stash:month} | |
| {stash:month}July{/stash:month} | |
| {stash:month}June{/stash:month} | |
| {stash:month}May{/stash:month} | |
| {stash:month}April{/stash:month} | |
| {stash:month}March{/stash:month} | |
| {stash:month}February{/stash:month} | |
| {stash:month}January{/stash:month} | |
| {/exp:stash:set_list} | |
| {!-- put it all together --} | |
| {exp:stash:get_list name="years" unique="yes" orderby="date_year" sort="desc"} | |
| <h1>{date_year}</h1> | |
| {exp:stash:get_list:months name="months"} | |
| {exp:stash:get_list:entries | |
| name="entries" | |
| match="#^{date_year}-{month}$#" | |
| against="date_sort" | |
| orderby="date_machine" | |
| sort="desc" | |
| prefix="entry" | |
| } | |
| {if entry:count==1} | |
| <h2>{month}</h2> | |
| <ul> | |
| {/if} | |
| <li>{title} ({date_year}-{date_month}-{date_day})</li> | |
| {if entry:count==entry:total_results} | |
| </ul> | |
| {/if} | |
| {/exp:stash:get_list:entries} | |
| {/exp:stash:get_list:months} | |
| {/exp:stash:get_list} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment