How to assign a field value as a tag name

151 views
Skip to first unread message

Alexei R

unread,
Aug 1, 2018, 8:28:25 AM8/1/18
to TiddlyWiki
Hello

Please help me to understend how can I assign value of a field as name of a tag.
Let say we have one tiddler with field named "field1" and it has value "John" and the second has the same field "field1" with value "Ringo".
How can I get the tiddler to be taged as "John" by refferensing to the string "John" by field name (in our case "field1") only?
How can I get both tiddlers to automaticly been tagged with value of theyer own field "field1": tiddler on as "John" and tiddler two as "Ringo".
Some how I need to make tiddler to display value of its particular field as tag...

FrD

unread,
Aug 1, 2018, 9:15:38 AM8/1/18
to TiddlyWiki
Hi,

Create a tiddler. Add a field ("myfield" for the code below to work). Assign a value to this field (even with white spaces).

Add this code inside the tiddler :

<$button>Field To Tag
<$set name="myfieldvalue" value={{!!myfield}}>
<$action-listops $field="tags" $subfilter="[
<myfieldvalue>]"/>
</$set>
</$button>



Regards

FrD

Alexei R

unread,
Aug 1, 2018, 9:39:51 AM8/1/18
to TiddlyWiki
I'v just tryed it doesn't work for me :-(
Isn't a simple way to just type somthing like {{!!myfield}}> into tag name input fild in tiddler editing mode?

FrD

unread,
Aug 1, 2018, 9:59:56 AM8/1/18
to TiddlyWiki
Hi,

I've tried it in https://tiddlywiki.com/ and it works for me. But maybe I misunderstood your question.

Regards

FrD

Mark S.

unread,
Aug 1, 2018, 10:08:34 AM8/1/18
to TiddlyWiki
FrD's method works -- but the code needs to be in the tiddler and you need to hit the button. Auto-tagging like you describe might be interesting. But I can see where it might get you into problems (like a field with massive amounts of text).

-- Mark


<$button>Field To Tag
<$action-listops $field="tags" $subfilter="[{!!myfield}]"/>
</$button>

Alexei R

unread,
Aug 1, 2018, 10:52:47 AM8/1/18
to TiddlyWiki
I'll try to explain it again:

Let say we have two tiddlers. One tiddler with a field named "field1" and it has value "John" and the another (second tiddler) tiddler has the same field "field1" but with enother value "Ringo".
What should I type into area marked with red circle?


In order to get the following result:

When "John" not hard coded as tag but it parametric value of "field1" field.

Jed Carty

unread,
Aug 1, 2018, 10:55:56 AM8/1/18
to TiddlyWiki
Tiddlywiki does not have a method for doing this. But what are you trying to achieve? If you already have a filed with the desired value in it you may be able to use the field value instead of the tag for whatever you are trying to do.

FrD

unread,
Aug 1, 2018, 11:55:55 AM8/1/18
to TiddlyWiki
Hi,

I don't much about the edit template, but apart from typing John :-), I can't think of any other solution.
Having taken a quick look at $:/core/ui/EditTemplate/tags which is the part of the edit template which deals with tags, ant at the tag-picker macro ($:/core/macros/tag-picker), I don't think they allow what you want to do.

Regards

FrD

FrD

unread,
Aug 1, 2018, 12:21:14 PM8/1/18
to TiddlyWiki
Hi,

Another way would be to use the "th-saving-tiddler" hook (if it's available). So when you save the tiddler it automagically add the value of field1 as a tag.
But that's way above my TW skills :-)

Regards

FrD

Mark S.

unread,
Aug 1, 2018, 12:53:48 PM8/1/18
to TiddlyWiki
Where do I learn about this hook?

Thanks!
-- Mark

FrD

unread,
Aug 1, 2018, 1:05:12 PM8/1/18
to TiddlyWiki
Hi,

One place to start : https://tiddlywiki.com/dev/ and type hook in the search area.

I don't know in what kind of module the JS code needs to be, and if it's a startup module, when does it has to start.

Regards

FrD

Alexei R

unread,
Aug 1, 2018, 2:42:12 PM8/1/18
to TiddlyWiki
I'm trying to use TiddlyWiki to map / document some company's IT infrastructure.
There are couple types of entities (tiddlers) servers, network equipment, software, OS, vendors, manufacturers, specs etc.
I provide relationships between entities by tags and individual properties of each entity by values of particular fields.
On the one hand TiddlyWiki's hierarchal table of content mechanism based on tagging.
On the other hand I decided to use tiddlers fields as kind of "variables" in order to stor and refer to a different values by field's name.
But in some cases for some tiddlers I discovered that tags and fields with identical value. For example in tiddler for server I need tag "Server" in order to link this tiddler to the server's branch of TOC and on the other hand I have comp_type field with value server in order to describe that this computer's type is server.
So in practice I have two variables with the same value that must be the same for both of them all the time. And if I would like to change the value I have to be very cautious and do not forget to change both of them simultaneously.
So I thought why don't I link them together. I'll have single variable that I could link to a tag and to a field. And change it in one place only.
Is it a way to use tiddlers field values to provide TOC structure?

Mark S.

unread,
Aug 1, 2018, 2:53:23 PM8/1/18
to TiddlyWiki

TonyM

unread,
Aug 1, 2018, 8:55:34 PM8/1/18
to TiddlyWiki
Alexei R,

Some food for thought

As an ICT Consultant, I plan to do exactly what you are doing to document IT infrastructure. I can see how to make a button that would take the value from a field and set it as a tag. Normally this would occur in the viewTemplate. I would have this button appear only if the field existed on the current tiddler using a tiddler tagged with $:/tags/ViewTemplate.

However I can feel it in my knowledge management senses that when you say "tags and fields with identical value" you have your design wrong in someway. If you cant design out this complexity
I believe you need to give tags or the values in fields primacy, and then allow existing values to provide the source when selecting the value for the other.

Further TOC's can be created by multiple means so tags need not be the only method, as mark pointed to in his PMario link.

You could make a fields values selectable from any source you wish, or you could set tag values based on values from any source you wish. So perhaps the answer already exists. 

Regards
Tony
Reply all
Reply to author
Forward
0 new messages