Tinderbox Forum

Is an Outline "index" attribute available or computable?

As I understand it the $OutlineOrder attribute – as its name implies – only gives the sequentially integer-numbered position of a note irrespective of its outline depth.

I was hoping that I could find (or code) an attribute that, in conjunction with a $DisplayName = rule, would assign automatically updating outline numbering prefixes to note names (in outline view) along the lines of

  1. First Main Heading
  2. Second Main Heading
    2.1 Subheading A
    2.2 Subheading B
  3. Third Main Heading
    3.1 Subheading C
    3.1.1. Sub-subheading

(I’m not bothered about the formatting of the outline ordering – Harvard, whatever is fine)

In case this is an example of an xy problem, I should explain that as well as providing some formatting I’m actually planning to use this attribute to assign a large number of atomic notes to the outline (i.e. the atomic notes would have user-assigned values for a $TopicIndex attribute and the Heading notes in the outline would query for atomic notes with $TopicIndex == their outline number). I hope that makes sense…

Thanks everyone as ever

I’ve done something like this with a Rule that looks at the outline level of the parent and prepends that to the current note’s outline level – with whatever formatting is desired.

Assuming you are numbering from root, you could store $TopicNumber, set via rule/stamp/agent/edict:

if($OutlineDepth==1){
   $TopicNumber = $SiblingOrder + ".";
} else {
   $TopicNumber =$TopicNumber(parent) + $SiblingOrder + ".";
}

Add this to a prototype you’ll use for all numbered notes first un-checking ‘Enabled’ for the rule or edict using either of those. I’d recommend an edict as you can alway force update an edict, e.g. if you move or delete a note.

Add a String-type user attribute ‘TopicNumber’ to you prototype

Also in the prototype select the Text Inspector and un-check ‘Enabled’ for the Display Expression, then add this code:

$TopicNumber+" "+$Name

Also set the OnAdd action of your prototype (here mine is called “Task”) like so:

Prototype|="Task";

Lastly ensure all you prototype, template, etc., folders are at the end of the root container so your first content note is sibling #1. The result is like this:

Untitled 2020-09-10 17-22-56

But let’s say you want the number to be under a root container. It still works, as long as the parent (not using the prototype) has no $topicNumber value:

Untitled 2020-09-10 17-25-06

As the code runs of values from the parent of the numbered note, the same prototype can populate more than one discrete set of numbering:

I think that will do it. :slight_smile:

1 Like

If you only want a trailing period that’s likely possible too, though it might make usage not as flexible as above. But, I’ll leave that as an exercise for someone else to try.

Indebted as ever Mark . Thank you

1 Like