I searched around and tried ChatGPT, but I couldn’t find a solution. I tried using the $list.each() function, but couldn’t figure it out. I am just looking for a way to create valid links from the ‘Tags’ attribute that I have assigned to a note.
Not 100% clear from the question, but I assume you want to make internal (in-TBX-doc) links in the $Text of a note. Additionally, I assume you want to link to a note whose $Name is the list item, and to use the same text as the anchor text at the source of the link. Apologies for asking, but this isn’t the only reading of the task above.
Thanks for your reply, Marc. Just to clarify, here is another example of what I am doing right now. As I don’t know how many Tags I might add in future, I would like to make this line of code more generic.
Loop through each tag in Tags Attribute, This works fine!
^if($Tags.count()>0)^^value($Tags[0])^^endif^
^if($Tags.count()>1)^^value($Tags[1])^^endif^
…
I am doing something similar for another purpose, which works pretty well. I collect all the children and create a loop through the ‘MySet’ attribute of each note, generating a valid HTML link to the note.
Export code tends to assume you are exporting links already existing in the Tinderbox document, which here is obviously not the case. It’s no problem to build the list in action code in the template (inside an ^action( action )^ wrapper) but that alone is not enough.
Yes, you have a list of values in $Tags but your HTML links need, for their target) either a full URL or—more likely in this scenario—relative URL to the exported page of another note in the same TBx. Also, those target locations need to be unique paths within the the document.
So the next pieces of the jigsaw are:
where are the ‘tag’ notes stored
do they export
is the exported filename the same case as the tag.
Tip: if unsure, check and don’t guess. Likely all the answer are simple, but don’t assume.
Lets, assume the answers are:
at path `/Tags’
yes
the case is the same as the tag value. IOW, “pear” for both not “pear” vs. “Pear”.
OK, so we know a note of an expected name path will be output when we export the file. Ee will assume the first tag is the word ‘plum’, and our note exporting the tag list is at path /Projects/X. Meanwhile the note for ‘plum’ is /Topics/plum.
I can see one might assume there is a function that ‘just’ does this. But consider these factors:
you are making an HTML link for a (document) link that doesn’t exist, so we can’t use export code (no link to export!)
only we know that values from $Tags have been set up elsewhere as a set of notes (i.e. to where the link points.
So, we have to calculate all this ourselves, which we can do (as above). Note the .. at the beginning of each path in the loop making the links is needed!
Assumption: containers/notes export to HTML using the same case as in their $Name—the info is case-sensitive.
Actually, it’s a third option, per earlier discussion up thread. The aim is to make items in a note’s $Tags export as a list of links to notes named for that tag. The latter was one of the early unclear points.
As explained above, there is a single ‘operator’ for this as there are a number of assumptions where the app can’t guess the user’s intent (again already explained).
I think the underlying, and understandable, misconception at work here is that Tinderbox will auto-create per-Tags-value notes and ‘just’ link to them. It can’t/doesn’t, and so a little bit of user work is needed. The constituent parts of the solution:
Thank you so much @mwra@satikusala for your feedback. This really helps a lot!
I collect notes representing central concepts/themes for my novel/project in Tinderbox. However, there may be other themes to which I only want/need to refer via a tag pointing to my Zettelkasten. I run the Zettelkasten on WordPress on my localhost. So Tinderbox HTML export and Zettelkasten WordPress work pretty well together.
If the ‘external’ tag notes have a consistent URL (except the actually tag value), then the method above will still work. I used an internal target partly as it makes it easy to show the method works.
If still stuck, the only thing we need (as we can’t) guess it is the local path to the zettelkastern tag. For instance, they could be .txt text files. a local URL would still work.
In today’s meet-up, it was discussed if using a function to get the action-code-compiled HTML code is a cleaner approach. It is! I was in a hurry.
This export-link-list-02.tbx (218.7 KB) is the same as above except note ‘Y’ uses a different template set to get the same HTML via a function. As so often, there is more than one way.