Hello, everyone
I've been using TiddlyWiki 5 happily for a few months now, for all my 
personal note taking and offline local knowledgebase, but one thing was 
keeping me from doing a full transition of all my data, and that was being 
able to have multiple tag fields per tiddler.
I figured out a relatively easy way to have multiple tag fields in a 
tiddler (sort of) and decided to share it here as reference since I've seen 
the same question popup a few times before, and maybe it is useful to 
someone else.


Disclamer

This isn't a true multiple tag field per tiddler, tags are all still store 
in the default built in tags field, me and my (very) limited coding skills 
haven't figured out entirely how to do that just yet.
This is just a hack to work around the missing desirable functionality, and 
simulate that feature, it is however, from a user point of view, both for 
viewing and editing purposes virtually the same as having as many tag 
fields as you like.

A little background

I'll use as an example the one piece of data I had yet to convert to a 
TiddliWiki format: my Software Database. I like trying out new software and 
always looking for better alternatives for what I currently use, and in the 
process I like to keep a record of what I find, where to get it from and 
it's strengths and weaknesses and features.I also like keeping some useful 
more technical info about them, like for example input and output file 
formats and protocols for each application.
This is where multiple tag fields come in handy, I'd like to have a field 
for input where I could specify that said program can read formats like say 
PSD, SVG, PDF and output or save to formats like Jpeg, Tiff or PNG. This 
could easily be done in the tag field, but I would like to keep that 
reserved for actual "categories" of software (like Image editors, or Text 
Editors, File Browsers etc.) and having file format tags there would 
quickly encumber it with a huge amount of tags, while still being hard to 
distinguish between input and output for each application without having to 
duplicate the set of tags.

Principle

So the trick here is filtering tags, if you do this to your tiddlywiki 
you'll basically end up with a different set of tags for each "custom 
field" that you would add, distinguished by a certain feature, either by 
name, by a certain tag, presence of a field, or any other filterable option.
After that all you have to do is filter out each set of undesirable set 
tags for each context.

How to

So following the above example of the software database lets image you want 
to have an *Input *field and an *Output *field for each tiddler tagged with 
Software and for each of these there will be a set of file format and 
protocol tags that can be assigned independently to each field. Instead of 
creating theses fields what we will do is create a different set of tags 
with a specific naming convention that will only e shown in the correct 
context.
For my use case I chose to distinguish these tags by name (could be with a 
tag or field or any other difference that can be filtered or with wiki text 
filters) , so all input tags would be named according to this scheme 
"*Format/Input/File 
Type Name*" and all output tags would be named "*Format/Output/File Type*"
Now first step would be to make sure these tags stay out of your way in the 
"regular" tag field; to do so you have to search for your tag editor system 
tiddler $:/core/ui/EditTemplate/tags


   1. Search for $:/core/ui/EditTemplate/tags with the Advanced 
   Search/System dialog.
   2. Overwrite the system tiddler by making a copy with the exact same 
   name (erase the number at the end)
   3. Now you need to override the tags that are shown both in the dropdown 
   search popup and the already applied tags by editing by editing the filters
      1. Edit the field mangler line <$list 
      filter="[all[current]tags[]sort[title]]" storyview="pop"> to never 
      display tiddlers that start with "*Format/*" in their name by 
      replacing it with the prefix operator
      <$list filter="[all[current]tags[]!prefix[Format/]sort[title]]" 
      storyview="pop">
      2. Edit the linkcatcher line <$list 
      filter="[tags[]!is[system]search:title{$:/temp/NewTagName}sort[]]"> to 
      never display tiddlers that start with "*Format/*" in their name by 
      replacing it with the prefix operator 
      <$list 
      
filter="[tags[]!prefix[Format/]!is[system]search:title{$:/temp/NewTagName}sort[]]">
      
      4. To be able to display the tags correctly you need to do the same 
   in the view template $:/core/ui/ViewTemplate/tags to exclude undesirable 
   tags
      1. Search for $:/core/ui/ViewTemplate/tags with the Advanced 
      Search/System dialog.
      2. Overwrite the system tiddler by making a copy with the exact same 
      name
      3. Replace the filter <$list filter="[all[current]tags[]sort[title]]" 
      template="$:/core/ui/TagTemplate" storyview="pop"/> with
      <$list filter="[all[current]tags[]!prefix[Format/]sort[title]]" 
      template="$:/core/ui/TagTemplate" storyview="pop"/>
      
      5. Now you need a way to edit these tags as if they belonged to a 
   different field, for that you need to create an additional tag editor 
   field, in the edit template that similarly filters out undesirable tags, or 
   in this case only includes the tags starting with the prefix "
   *Format/Input/*", for that
      1. Search for $:/core/ui/EditTemplate/tags with the Advanced 
      Search/System dialog.
      2. Make a copy of this tiddler with whatever name you want
      3. Edit the field mangler line <$list 
      filter="[all[current]tags[]sort[title]]" storyview="pop">
      to only display tiddlers that start with "*Format/Input/*", in their 
      name by replacing it with the prefix operator
      <$list filter="[all[current]tags[]prefix[Format/Input/]sort[title]]" 
      storyview="pop">
      4. (For the hypothetical output field one would similarly have to do 
      this with <$list 
      filter="[all[current]tags[]prefix[Format/Output/]sort[title]]" 
      storyview="pop">)
      
      6. To make this "virtual field" editor completely independent from 
   the regular tag editor we must now change all the state and temp tiddlers 
   that make it work. This is easier to do in an external text editor
      1. Use it's search and replace function to substitute all occurrences 
      of {{$:/temp/NewTagName}}
      with {{$:/temp/NewInputName}} or whichever name you desire
      2. and $:/state/popup/tags-auto-complete with
      $:/state/popup/input-auto-complete
   

And you should be all set, now you may want to do some filtering so that 
your additional tag viewers and tag editors only show up in the correct 
tiddlers (only the ones tagged with Software in this case) by adjusting 
your view and edit templates with additional filters.

Problems and weaknesses of this method

There are a few caveats to this method, namely you can't really share the 
exact same tags between different "virtual fields", since you would then 
have no way to know to which field they are applied to, also there's an 
additional considerable maintenance overhead, since you'll have to manually 
distinguish all tags belonging to a certain field, either by assigning a 
different name system (with a prefix or a suffix) or assigning a certain 
tag, or adding specific field, so they can be filtered in/out according to 
context. If you really need this sort of categorization however it may well 
be worth the extra trouble of maintaining it.

Sorry for the wall of text, I hope this is helpful to other people, also if 
I'd like to hear your opinion about it or if you have a better method 
please do share! :)
























-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/cfafb8b6-b0e4-491c-a2c2-034526d82c38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to