Can tag adding trigger field creation?

164 views
Skip to first unread message

Misterel85

unread,
Jan 24, 2021, 8:48:10 AM1/24/21
to TiddlyWiki
Hi,

I started gathering all the drama activities I have collected over the years from miscellaneous sources into a TW single file.

To quote the source of an activity (= one tiddler per activity / exercise), I have used so far:
  • a tag, itself tagged as 'Source', and that holds the main source reference in its text field (website, book, event title and description);
  • a 'source_detail' field in the activity tiddler, that contains the  reference details of the activity, such as the book page number, etc.
Both the source tag's text field and the 'source_detail' field are then transcluded into the activity, thanks to a macro adapted from Tobias Beer's filter and list examples.

That works great when the activity has only one source. Some (nearly) identical activities, however, can be found on several sources: books, web pages, notes from events I took part in, etc. And I would like to quote them all in the activity tiddlers.

So, here's what I would like:

  1. I create an activity tiddler.
  2. I create the corresponding generic source tag tiddler(s) if they don't already exist. Ex. a tiddler tag whose text field holds info about a (hypothetical) 'dramatis.com' website would be called 'dramatis' and tagged 'Source'.
  3. For every time I add a source tag to the activity tiddler, TW checks whether a corresponding source detail field exists in that current activity tiddler.
  4. If not, it retrieves the name of the tag and creates a new field named after that tag. In the example above, a corresponding field named 'dramatis_detail' or simply 'dramatis' would be added in the current activity tiddler.
  5. If I delete a source tag (ex. the 'dramatis' tag), the corresponding 'dramatis' field would also be deleted. (That step may not be necessary if step 3 is implemented.)

Hope my explanations were clear. I can't work it out because I've been a TW beginner for months, I can't understand everything in the very technical and programer-oriented TW documentation, and so far, my needs have always been very basic. Time for me to improve my TW knowledge!

Do you think something like that could be done? If not, would anybody happen to think of a similar solution on how to manage multiple sources and reference details, and the  different steps to implement it?

Thanks.

Stéphane L.

TW Tones

unread,
Jan 25, 2021, 7:37:43 PM1/25/21
to TiddlyWiki
Stéphane L. 

You are aware that in your section  So, here's what I would like:  you are in many ways forcing the solution rather than truly stating "what you would like". Perhaps avoid tiddlywiki jargon and ask again, then responders can suggest solutions beyond the limitations you are implying.

As far as I can see, In database speak you want multiple values in your source field, there are many ways to achieve this in tiddlywiki.

I recently discovered we can use the tag-picker macro against another field, try this;

Source tags: <<tag-picker tagField:"source">> 
<$list filter="[{!!source}enlist-input[]]">
  <<tag>>
</$list>

  • You can also trigger actions on selection with the tag picker.

Regards
Tones

Misterel85

unread,
Jan 27, 2021, 8:50:03 AM1/27/21
to TiddlyWiki
Hi Tones,
Thanks for your reply.
Sorry if I didn't clearly express 'what I would like', and sorry if providing steps on how I was seeing the mechanism I had in mind didn't help. I'll try to improve what I have already done and rephrase it accordingly.
Anyway, the macro you provided is very interesting and could be really useful. It should be added to TiddlyWiki's documentation which doesn't provide any examples about the tag-picker.
Also thanks for your 'standard nomenclature' you recently posted about. This is a great piece of work!
Cheers,
Stéphane

TW Tones

unread,
Jan 28, 2021, 6:02:30 AM1/28/21
to TiddlyWiki
Stéphane,
  
Can tag adding, trigger field creation?

To answer this question directly if you provide the method to add a tag, like construct your own button, you can always add an additional action to create a field. 

I am sure we can find a way to hack the existing add tag system to also add a field but do you want this field added every time any tag is added?

When you are ready explain what you are trying to achieve with this tag and field and when or if, its always needed, what if the field already exists etc...

Regards
Tones

Pit.W.

unread,
Jan 28, 2021, 6:45:15 AM1/28/21
to tiddl...@googlegroups.com

Stéphane,


I had the same issue and I solved it by creating a special button, which adds both a tag and one or more fields.

When using it for some time it occurred to me that - if I need both a tag and a field with always the same contents, something is flawed with my data model or my processes, since I am creating redundant information stored in different places.

And it took only a short time until these redundancies made me very unhappy....

Also see Tones last sentence: "what if the field already exists" - also a way to become unhappy ;/


Pit.W

--
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 tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/881321cc-c7a2-4e10-ab5f-0c8091b6740cn%40googlegroups.com.


_________________________________________________________________
________________________________________________________
Ihre E-Mail-Postfächer sicher & zentral an einem Ort. Jetzt wechseln und alte E-Mail-Adresse mitnehmen! https://www.eclipso.de


Misterel85

unread,
Feb 1, 2021, 7:34:37 AM2/1/21
to TiddlyWiki
Thanks for your input, Tones and Pit.W.

Sorry for this (very) long post again.

Here is an outline of how I see things in a tiddler. The aim is to avoid copying and pasting redundant information from one activity to the other with a little bit of automation. Any solution or idea to achieve that would be welcome.

---
Tiddler title: "This is one activity"
Contents: "A description of that activity. Blah blah…"

Tag1 name: thisdramabook
Tag2 name: dramatis
TagN, etc.
=> Each of these tags contain general reference about the source, for instance in Tag1: "This Drama Book - an extraordinary drama book". That info is then shown into the activity tiddler via transclusion.
I tagged these tags with 'source' because I use a few other tags to build a table of contents.

Field1 name: thisdramabook
Field1 contents: 'page 15.'
Field2 name: dramatis
Field2 contents: "exercise 3, posted by John Doe on Wednesday 12th."
FieldN, etc.
=> Each field would contain specific details about where I found the activity itself in the source referenced by the tag. The field is created when I add its tag namesake and I can manually add contents to it, that would differ from an activity to the other.
---

So, if I need to print the activity, the text would be something like:

---
"This is one activity.

A description of that activity. Blah blah…

Source(s):
– This Drama Book - an extraordinary drama book - p. 15.
– Dramatis - an extraordinary drama website - exercise 3, posted by John Doe on Wednesday 12th."
– …
---


@Tones,
My answer to your question:
'do you want this field added every time any tag is added?'
would be 'yes', because I can't find any other (better) solution to what I am trying to achieve. I'd rather keep the specific source details away from the activity description.

@Pit.W.
You're quite right about not needing both a tag and a field to hold the same contents.
That's not what I want to do, but you'll notice that both are linked: a source detail field would be created in a tiddler only if there is a corresponding source tag.


TiddlyWiki makes me feel both amazed at what it can do, keen about what I could do with it, and frustrated with what I can't achieve! :-s

Stéphane

Javier Eduardo Rojas Romero

unread,
Mar 2, 2021, 2:07:55 PM3/2/21
to tiddl...@googlegroups.com, stephan...@wanadoo.fr
On Sun, Jan 24, 2021 at 05:48:10AM -0800, Misterel85 wrote:
> So, here's what I would like:
>
> 1. I create an activity tiddler.
> 2. I create the corresponding generic source tag tiddler(s) if they
> don't already exist. Ex. a tiddler tag whose text field holds info about a
> (hypothetical) 'dramatis.com' website would be called 'dramatis' and tagged
> 'Source'.
> 3. For every time I add a source tag to the activity tiddler, TW checks
> whether a corresponding source detail field exists in that current activity
> tiddler.
> 4. If not, it retrieves the name of the tag and creates a new field
> named after that tag. In the example above, a corresponding field named
> 'dramatis_detail' or simply 'dramatis' would be added in the current
> activity tiddler.
> 5. If I delete a source tag (ex. the 'dramatis' tag), the corresponding
> 'dramatis' field would also be deleted. (That step may not be necessary if
> step 3 is implemented.)

The following tiddler + setup should:

* add a "Sources" field which will show up whenever you edit a
tiddler, where you will be able to search/select tags, just like the
regular tag interface; it should show up at the bottom of a tiddler
when editing it.

* When selecting a tag *there*, it will be added to the current
tiddler, AND, a new field called "<tag> detail" will be added, if
the tag itself is tagged with the "source" tag.

NOTE: it will only work with tiddlywiki 5.1.23 (latest release as of
today), since it depends on some new features of the "tag-picker"
macro.

To add it to your tiddlywiki, create a new tiddler, as follows:

title: doesn't matter, name it as you wish
tags: $:/tags/EditTemplate
content: (omit the % START % / % END % markers below)
%%%%%%%%%%%%%%%%%%%%%%%% START %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\define acts()
<$list filter="[<tag>tag[source]]">
<$action-setfield $tiddler="$(currentTiddler)$" $value="FILLME" $field={{{ [<tag>addsuffix[ details]] }}} />
</$list>
\end

Sources: <$macrocall $name="tag-picker" actions=<<acts>> />
%%%%%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

If the above provides what you need, you should then consider using that
code to replace the original tags widget in the edit tiddler interface. To do
that, I would:

* save and backup my wiki ;)

* copy-paste the original tiddler (its title is
$:/core/ui/EditTemplate/tags ), into this new tiddler you created.

* integrate the "acts" macro, and the changes to the "tag-picker"
macrocall that I suggested above, to the copy-pasted tiddler content.

* put the tiddler in the proper place in the edit interface: Click on
the tag-pill for the $:/tags/EditTemplate of the new tiddler, and
drag-and-drop the new tiddler's title to the desired position

* Edit the $:/core/ui/EditTemplate/tags tiddler, to remove the
$:/tags/EditTemplate tag from it, so it doesn't show up in the edit
interface anymore.

* Enjoy the new setup!

Cheers,

--
Javier

Misterel85

unread,
Mar 21, 2021, 5:21:49 PM3/21/21
to TiddlyWiki
Javier,

Sorry for not replying earlier. I have been very busy this month.

Thanks a lot for your solution! That's great!
I tested your tiddler to see how it would work and I can tell tell you I'm very happy with the result.
I haven't been through all the steps you suggest, but I'm sure they work perfectly. I need to finish the TOC beforehand, as long as I have access to the built-in tag picker. (Yes, I know I can get it back easily, but once the structure is done, I don't want to modify it unless it is really needed.)

For the moment however, I have put that project on hold as it wasn't a priority.

Anyway, thanks again for your ready-made solution.

Cheers,

Stéphane
Reply all
Reply to author
Forward
0 new messages