I’ll upload my edited version for you file at the end of the post. But the main assumptions are as follow…
We will use a container or agent for export. In either case:
- $Sort set for ‘MyDate’, reverse order
- $SortAlso set for ‘Name’
So, all children/aliases sort in reverse ($MyDate) date order—i.e. most recent first—and in A–Z order within groups of notes with the same MyDate.
We need two new templates:
- t_date-page. This is the ‘wrapper’ template used by the agent or container to generate the list. It transcludes each child using template…
- t_date-item. Checks if current note is first sibling or has a different $MyDate to its previous sibling. If so, the formatted $MyDate is listed before the note’s data ($Name, etc.)
The code in the latter template looks like this (ignore the forum’s code-colouring which is getting confused here):
Note that sibling order is intrinsic so as long as the parent container/agent is sorted correct see above), the code works fine with original notes or aliases in an agent.
Also note that when using
!= with Date type data, the time portion of the Date/time data is ignored. To illustrate this I changed the time of day, but not the day in several notes (‘Bobcat’, ‘Lynx’). This is why the outline sort order may differ slightly from that expected. To sort ($Sort) only on day and not date-time of $MyDate you would need to store the date-time in another attribute, but re-setting the time portion of each to the same time.
I’ve added an agent to the TBX so you can see the same template working in either a container or an agent listing that container’s contents.
Here is the TBX: conditional export ed1.tbx (137.0 KB)