Let’s have this for a case:
we have a bunch of notes in our working papers, and those notes are all viewed in another reconciliation template, with links to those notes, and where we explicitly see which notes are starred and which are not, as the ones who are starred need to have a number:
Now, those numbers that are created in the overview template, need to be displayed too in the notes themselves, and take into account that, as soon one note is unstarred, it takes the correct value as a number (as note 3 will become 2 when the second note is unstarred e.g.):
How can we built this? First, we’ll create our overview template (with overview_notes
as name of the handle), as the info needs to be taken from there:
{% comment %}create array to loop over notes{% endcomment %}
{% assign notes_array = "note_a|note_b|note_c" | split:"|" %}
{% assign note_nbr = 1 %}
{% comment %}show all notes{% endcomment %}
{% stripnewlines %}
| Nbr.
| Title
{% newline %}
|----05%----:
|-----------#
{% for item in notes_array %}
{% comment %}link to note = recon drop{% endcomment %}
{% assign note = period.reconciliations[item] %}
{% newline %}
| {% comment %}create automatic number, based upon the fact if recon is starred or not{% endcomment %}
{% if note.starred? %}
{% linkto note %}{{ note_nbr }}.{% endlinkto %}
{% comment %}the numbering needs to be taken into result to display in the notes themselves{% endcomment %}
{% capture nbr_of_note %}nbr_{{ item }}{% endcapture %}
{% result nbr_of_note note_nbr %}
{% comment %}add 1 for the next numbering in the note that is starred{% endcomment %}
{% assign note_nbr = note_nbr | plus:1 %}
| **{{ note.name }}**
{% else %}
| *{{ note.name }}*
{% endif %}
{% endfor %}
{% endstripnewlines %}
Yes, for now, you’ll need to create an array to loop over the correct templates you want (keep an eye on this topic, as we’d like to automate this obviously, but for now, that is not possible).
The result tag nbr_of_note
is quite important, as for note A it’ll create a result-tag named nbr_note_a
, for note B nbr_note_b
, and so on… That’s what this code is for:
{% capture nbr_of_note %}nbr_{{ item }}{% endcapture %}
We will call upon these results in the individual notes:
{% comment %}get number for the current note, which is a result from the overview_notes templates{% endcomment %}
{% assign current = "note_a" %}
{% capture nbr %}nbr_{{ current }}{% endcapture %}
{% assign nbr_note = period.reconciliations.overview_notes.results.[nbr] %}
{% stripnewlines %}
| {{ nbr_note }}.
| Note A
{% newline %}
|----02%----
|-----------#
{% endstripnewlines %}
As you can see, we’ll need to duplicate this code in every note (which is not what we’d want to do, but we are also working on that!), and the only thing you’ll need to change is:
{% assign current = "note_a" %}
and change it into the correct handle of the current template you are developing in.
If the template is unstarred, no result tag will be made in the overview template. This is the way you can have an overview of certain templates with correct numbering.