Set attribute that links to notes

Hi there,

I’m writing to the Tinderbox Forum because I’m in need of some assistance. I’m currently working on prototyping notes, specifically a Module and Lesson prototype. I’m hoping to create a user-made attribute within the Lesson prototype called “Belong to Module” that will allow me to select the appropriate module that the lesson corresponds to. Ideally, this attribute would provide a dropdown box for easy selection.

Does anyone have any recommendations for how to create this attribute or any resources that might be helpful? I appreciate any guidance or advice you can offer.

Thank you!

Hi, welcome back to the forum. Here are some suggestions.

Making a user attribute.

Decisions before starting:

  • Data type. There are a number of data types you can use, but it is likely your attribute value is textual. Next choice, is it single or multi-value, i.e. does the lesson only ever occur in a single module or is it taught in multiple modules. If single, use String-type; if multi-value, use a Set-type
  • Attribute name. The overall ‘rules’ for naming are here but a reasonable choice for String attribute would be InModule or for a Set InModules. The plural in the latter case helps remind you the attribute can hold multiple values.

Creating the attribute

Although there are various quicker ways to make an attribute, but those are best used once you know the configuration options. The standard way to make a new user attribute is via the User sub-tab of the Document Inspector:

[In the following I’ll assume we are creating a String-type called ‘InModule’]

Click the grey button (top-right, after the Attribute pop-up) and choose New user attribute.

In the Name box, type the new attributes name, e.g. InModule.

Use the Check pop-up to set the desired type of ‘string’ (or whatever type you have decided upon)

In the Description box, type a short description to remind yourself of the purpose of the attribute. Important, when done editing this you must press Return to save the text. If you need a link break in the text, use Shift+Return instead.

One more task before you close the Inspector…

Select the prototype ‘Belong to Module’ and on the Inspector tick the Displayed attribute for selected notes tick-box. this attribute is now a Displayed Attributes for that prototype.

Other considerations
When editing attribute ‘InModule’ in a note’s Displayed Attributes, the values pop-up will show the list of existing values for the attribute. Read the linked article as the indications on the list differ for Strings vs. List or Set types. It is possible to pre-populate the list using suggested values. Having read that, if you want to use the feature, return to the Inspector (above) and edit your attribute’s suggested values (see the Suggested box).

1 Like

Thank you @mwra
As always, your help is much appreciated!

I still don’t understand how to let the attribute inModule automatically show all the Module prototype notes; allow me to choose one and have this one clickable so I can go straight to that note.

Three modules: History, Philosophy, and Poetry. All were created with Module prototypes.

A lesson: one displayed attribute is inModule. When I click, a dropdown opens with three options populated automatically: History, Philosophy, and Poetry. I chose, let’s say, History. After I decided, whenever I click History in the attribute, it jumps to the History note.

The clickable bit is not possible in Tinderbox. Why? Becasue is no user-defined UI in Tinderbox, such as you might get in a database app like Filemaker.

But you could make an export template such that in Preview mode (i.e. still in Tinderbox) the ‘History’ value would be a link that would take you to the History note—still in Preview mode. Of course if you don’t know or don’t wish to use preview mode (as that creates possible other issues) then there is not a solution.

Another route might be to write (custom) action code to add a link to the note named in $InModule and add it to the note’s $Text. Again that might not be ideal. IOW, the link would work but it is now in the text of the lesson. But, clicking such a link—if made—would create a working link in $Text that if clicked would take you to that note.

Okay, thank you for that information.
Can I do the other part? This means that I can have the inModule attribute populate automatically with all notes built with the Module prototype and let me choose one.

I’m getting confused as this seems to be a different task. So, $InModule can’t be a string as you want it to hold multiple values, so a Set or a List. as you only want each note to list once, a Set (that auto-de-duplicates) is the best bet.

As you will know from the links posted earlier, an attributes popup value list shows:

  • values used for the prototype in other notes in the TBX
  • optionally, suggested but as yet unused values

But, you want the attribute to list the values of a different attribute (the $Name of notes using the Module prototype. Not the same. But, we can do this, I think (too busy to write/test a demo at present), the following way:

  • Make a Set-type attribute named ModuleSet
  • In the prototype ‘Module’:
    • Add ModuleSet as a Displayed Attribute
    • Make/add a Rule: $ModuleSet=$Name;

Now all Module-based notes with store (only) their $Name in their $ModuleSet. As a result any note will now show all those note titles as the value-pop-up list (or currently used values) for $ModuleSet.

Give that a try.

[Edit: improved formatting of Rule code]

I’m sorry for the confusion.

tried this. MudueSet is now populated with Module and Lesson. Not the names, but literally : Module and Lesson.

by the way, I need ModuleSet to be Displayed Attribute inside Lesson prototype and not inside Module prototype. So I did that but it still give the same result.

Sorry to hear that. Can you please post your test TBX showing this. Easier to investigate the code than imagine what the error might be. Plus, having a common frame of reference helps surface unmentioned assumptions. :slight_smile:

†. The forum allows TBX (or Zip if big) uploads. Need not be a massive document - just something showing the issue at hand and with source data to test the planned (plus edge cases if relevant" false negative/positive matches)

I’ve tried it again, and now it works!

A minor thing: It also puts the word Module inside the set: “Philosophy,” “History,” “Poetry,” and “Module.”

Anyways, Thank you very much, @mwra :smile:

Probably because the rule is enabled in the prototype. Select the Module prototype note, open the Rule Inspector and un-tick the box bottom left, the rule only runs in the inheriting note. Now in the prototype, delete the value (which will be ‘Module’) and all should be good.

If you read about the RuleDisabled attribute, it will explain about what happens when you un-ticked that box above.

HTH :slight_smile:

1 Like