Tinderbox Forum

How do I populate a tag list from a list of docs inside TB?

I’m working with a list of terms that can be tags, but I want to keep the tags available as documents in the TB file (to allow discussion and linking to documents which are tagged, etc.). What I’d like to do is to have my own attribute work as a set populated by the titles of these documents, so when I tag, I’m using the list.

I don’t know how to get the list of titles into the Attribute!

This is a really newbie question, sorry, but I’m not sure whether I need to make an agent that collects this, or whether I can populate the attribute dynamically.

Many thanks!

An agent would populate the attribute dynamically.

I think it would help to be concrete here. What are these documents? What, specifically, do you want to store in the attributes of these notes?

Hi, many thanks. the tag list just a list of items (individual notes) with my intended tag text as a title, all children of a folder called “MyTag List” (as an attribute, I can call them “MyTags”). Each of the documents has a paragraph describing syntax and usage of the tag.

What I want is to use this list of tags as the options in a set of a “MyTags” variable in other notes, so that the tag list to be used in those notes is selected from the list of tags that’s somewhere else in the TB file. I don’t know how to limit the user from inputting new tags in the field directly (instead of them coming from the lookup of the formalised list), but I’m the user and this would be my own discipline!

If I understand you correctly, the idea is to set up an Edict (the tags don’t change very often) which collects the titles ($Name) of the children documents below “MyTag List”, but I don’t know where to put this list or where to put the Edict, nor how to have this list act as the Set for the dropdown which would be MyTags in the target documents.

Does this make sense?

Many thanks again!

I think we have two separate things you want to do.

1.Create a list of possible tags by scanning a collection of notes, each of which represent a tag. For example, the note /Tag Documentation/Costly shows that “Costly” is one possible tag, and its text might explain the criteria that something must meet if it is Costly.

  1. When you create a new note inside the container Working Notes, it has displayed attributes $MyTags, which is empty, and $MyTagList, which has a copy of the list of all the tags.

Is that correct?

Hi, and thanks again, I think we’re on the right path.

Using your example, $MyTags would be the attribute associated with a note; what I want is for the list of tags you note in your para 1. to be the options that come up when I want to associate one or more elements to $MyTags (which would be a Set attribute, I guess).

Super thanks again!

Here’s one idea.

  1. Make a prototype which your newly-created notes will adopt. Let’s call it ITEM. It can have $MyTagList and $Tags as displayed attributes

  2. The OnAdd action of the container Working Notes sets the new note’s prototype to ITEM.

$Prototype="ITEM"
  1. Make another note, somewhere else. Manually set its $Tags to include all the tags you want to have. Eventually, we’ll build this automatically, but for now we can simply do that by hand.

Now, when you add a note to Working Notes, the dropdown menu for $Tags has all the tags of interest.

I’m with you here, but my interest is in the automatic population; there are several prototypes that will have this $MyTags field (to distinguish it from the built-in $Tags field).

Going back to your example, which just has one prototype, when you say to “Make another note somewhere else,” do you mean to manually list the $MyTags list in the prototype ITEM? If it’s another note somewhere, how does it get linked to the tags that come in when a note inherits from the prototype ITEM?

The pulldown menu for a set-valued displayed attribute contains a list of all the values currently in use.

So, suppose we want the menu for $MyTags to contains four items:

  • Redstone
  • Atlas
  • Aegina
  • Titan

These will appear in the pulldown menu for $MyTags if some note’s $MyTags has these values. The “other note somewhere else” is simply a way to make sure each of the tag values is used in the document.

Ok, but is there any way to auto-populate this?

Can I read in the children document of my tags container doc to create the list, so that I manually copy and paste this into the Tags field? How would I do this?

Thanks so much for your patience!

Sure. Let’s suppose the notes about tags are inside a container named About The Tags. We could create an agent that finds them:

Query: inside("About The Tags")
Action: $MyTags = $MyTags + $Name;

Since $MyTags is (I presume) a set, adding a tag we already have listed does nothing. But if we add a new note inside All The Tags, it will be indexed.

Another way to do this is to make a regular note with a Rule or Edict:

$MyTags=collect(children("All The Tags"),$Name)

Great! It works!

I put the Edict in the Edict box of the general inspector, then I ran it, and the code disappeared! Isn’t it supposed to stay somewhere?

Sorry: I don’t know what happened. Remember to hit [Return] after entering the action?

Hmm. I did that, hit [Return] and it stayed, but then when I went back to this, it was gone.

Are Edicts associated with a particular note, or are they associated with the TB file altogether? I just don’t know why it disappears…

Edict, like rules, are attributes of a note, like any other.

So should I just make a note somewhere and stack all of my Edicts in it (the note would be called “System Setup – Don’t Erase”)?

That would be very unusual. Rules and Edicts are typically designed to apply to the note that runs them. Very often, they’re inherited from a prototype.

Ok, so the way I should do it is put it in one prototype which generates a note that has this field. But can I use the field in notes that don’t inherit from that prototype, but which have the field? In this last case, would the field be updated going forward?

I’m not sure what you’re asking here; every note has every attribute.

Ok, then thanks a million. It seems that every note has the attribute and an Edict in another note updates the field in every note.

I then need only to have the edict trigger on the note that holds the edict, and it will update the field in every note.

I think this will resolve my question!!

Many, many thanks.