Is there a way to use the journal-date field to organize journal entries with nested subsumes?

@Brian_Radspinner I think the code pattern within your example and variations of it is a useful approach to this and similar problems. In this one you are nesting the lists, but we can also use the format date (to different periods like YYYY) then the each:value[] to get a list of those values, we can save this in a variable, using $set filter= in this case the years in our data set.

  • Then we can use this as the outer group
  • Then we could go on to determin another set of the form YYYY0MM
    • No need in this case because this is the key to inner group

If this set of years, is in a variable, before we use it we could give the user the opportunity to select from that set and use the result to itterate the data.

  • I am interested in exploring this pattern because it is a way to allow selection of a range of date based on the date itself.
  • Note each:value[] seems equivalent to unique[]

I will edit this reply and give an example, the following example uses journal entries with a journal-date

\function month-heading() Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec +[nth<month>]
<$set name=journal-years filter="[get[journal-date]format:date[YYYY]each:value[]!sort[]]">

''Years to include: ''<$list filter=<<journal-years>> variable=year>
<$checkbox listField="temp-years" checked=<<year>> unchecked=""> <<year>>,</$checkbox>
</$list>
<$list filter="[enlist{!!temp-years}]" variable=year>
<details><summary>Year <$text text=<<year>>/></summary>

<$list filter="[range[12],[1]pad[2]]" variable=month>
<$let date-prefix={{{ [<year>addsuffix<month>] }}}>
<details><summary><<month-heading>> ^^<$text text=<<year>>/>^^</summary>
<$list filter="[has[journal-date]!nsort[journal-date]] :filter[get[journal-date]prefix<date-prefix>]">

</$list>
</details>
</$let>
</$list>


</details>
</$list>

</$set>

And looks like this;

Snag_34992fe

  • After opening Year 2023 and Month Dec

Notes;

  • Notice how month-heading is an array that uses <<month>> to find an entry in it.
  • Selecting the years shows how we can use and save such parameters for perfomance
  • There are 12 month in any years so I generate them rather than look them up, (we could have empty months, so you could add a count of journals to the month summary).
    Snag_351a9da
2 Likes

Wow, the explanations are all so fascinating! So many things to try, and links for further study. Thank you everybody!

. . . some time later . . .

@etardiff

I loved the links and explanations! But I could not get any of your link suggestions to work, neither in 5.1.22 nor the upgraded version. I think the problem is not your code but the code I was trying to plug yours into.

@Brian_Radspinner

The Holy Grail! Your code was the closest to what I wanted and it was EXACTLY what I wanted after I tweaked this part of your code:

<ul>
<$list filter="[tag[Journal]] :filter[get[journal-date]format:date[YYYY MMM]match<YEARMONTH>]" variable="ENTRY">
<li><$link to=<<ENTRY>> />&emsp;(<em><$view tiddler=<<ENTRY>> field="journal-date" format="date" template="YYYY-0MM-0DD"  /></em>)
<br><$transclude tiddler=<<ENTRY>> /></li>
</$list>
</ul>

. . . to this:

<$list filter="[tag[Journal]] :filter[get[journal-date]format:date[YYYY MMM]match<YEARMONTH>]" variable="ENTRY">
<$macrocall $name=subsume tid=<<ENTRY>>/>
</$list>
  • I got rid of the <ul> etc because I didn’t need the extra indent.

  • At present I didn’t need the date appended to the title because the date is currently the beginning of my title. (It’s a holdover from old habits and ways of sorting and considering a bit of redundancy as an extra margin of safety. But I may use it in the future.)

  • I saw what you did with variable=ENTRY and tried plugging ENTRY into David Gifford’s subsume macrocall a la <$macrocall $name=subsume tid=<<ENTRY>>/> and voila . . the holy grail! Even though it’s not subsumes all the way up, it’s exactly what I wanted!

HOWEVER, your code (changed or unchanged) will not work in 5.1.22, only in the 5.3.1 version. How do I get it to work in the old version?

Would it have something to do with format:date not being recognized yet in the old version?

@TW_Tones

  • I was able to get the subsume macrocall to work in your code as well.

  • Likewise your code only works in 5.3.1 not in 5.1.22 but I think that is natural because you are concentrating on using the latest.

Once again, thank you everybody so very much!

The :filter prefix came in with 5.1.23, so it just missed your cut-off requirement. You can try this alternative version with the Subsume macro:

<$list filter="[tag[Journal]get[journal-date]format:date[YYYY]each:value[]sort[title]]" variable="YEAR">
<details>
<summary><strong>Journal <<YEAR>></strong></summary>

<$list filter="[tag[Journal]get[journal-date]prefix<YEAR>format:date[YYYY MMM]each:value[]sort[title]]" variable="YEARMONTH">

<details>
<summary><<YEARMONTH>></summary>
<$list filter="[tag[Journal]has[journal-date]]" variable="EVERY-ENTRY">
<$list filter="[<EVERY-ENTRY>get[journal-date]format:date[YYYY MMM]match<YEARMONTH>]" variable="EACH-ENTRY">

<$macrocall $name=subsume tid=<<EVERY-ENTRY>>/>
</$list>
</$list>
</details>
</$list>

And a more generalized version without subsume:

<$list filter="[tag[Journal]get[journal-date]format:date[YYYY]each:value[]sort[title]]" variable="YEAR">
<details>
<summary><strong>Journal <<YEAR>></strong></summary>

<$list filter="[tag[Journal]get[journal-date]prefix<YEAR>format:date[YYYY MMM]each:value[]sort[title]]" variable="YEARMONTH">

<details style="margin-left: 1em;">
<summary><<YEARMONTH>></summary>
<ul>
<$list filter="[tag[Journal]has[journal-date]]" variable="EVERY-ENTRY">
<$list filter="[<EVERY-ENTRY>get[journal-date]format:date[YYYY MMM]match<YEARMONTH>]" variable="EACH-ENTRY">
<li>
<$link to=<<EVERY-ENTRY>> />
<br><$transclude tiddler=<<EVERY-ENTRY>> />
</li>
</$list>
</$list>
</ul>
</details>
</$list>

@Brian_Radspinner
Both codes return a blank tiddler in 5.1.22

Just popping in to say you were right about format:date being an issue; the format operator itself was only introduced in 5.1.23.

Sorry my code didn’t end up working for you! I didn’t read the thread as closely as I should have and wasn’t thinking about older versions of the core.

I realize this question is obvious… You probably have your reasons… But the new features have their reasons too — they make things possible, and make things concise, that are otherwise more cumbersome (or require resorting to javascript).

So, is there are obstacle to upgrading? If there is, can we help coach you past it? :hugs: