Button that read tags from a field.

74 weergaven
Naar het eerste ongelezen bericht

vinvi...@gmail.com

ongelezen,
2 jan 2021, 09:52:4202-01-2021
aan TiddlyWiki
Hello,

I have a button to create a new tiddler.
With    \define TAGS() [[$(currentTiddler)$]] [[Tag 2]] [[Tag 3]],  I can tag the new tiddler.


\define BUTTON-NAME() Enter >
\define BUTTON-COLOR+SIZE() btn btn-link btn-sm
\define BUTTON-TEXT-COLOR() color:
\define TIDDLER-TITLE() $(currentTiddler)$ ENTER-SPECIFIC-HERE
\define TIDDLER-TAGS() [[$(currentTiddler)$]]
\define TIDDLER-TEMPLATE() {{||$(currentTiddler)$-SPECIFIC-TEMPLATE}}

<$button type="button" class=<<BUTTON-COLOR+SIZE>>>
<$action-sendmessage $message="tm-new-tiddler" 
title=<<TIDDLER-TITLE>>
text=<<TIDDLER-TEMPLATE>>
tags=<<TIDDLER-TAGS>>
/>
<span style=<<BUTTON-TEXT-COLOR>>><<BUTTON-NAME>></span>
</$button>


What I want is for the button to read the tags from a field;
tags={{!!tiddler-tag}}

My problem is that [[$(currentTiddler)$]] in a field doesn't work.

How do I make this work?
Thank you,

Xavier Cazin

ongelezen,
2 jan 2021, 11:19:5602-01-2021
aan tiddl...@googlegroups.com
Hi,

Since the tags field is of the list type, you need to retrieve its content either directly from another list-typed field (that is list or tags), or indirectly by transforming the string content into a list.

In your example, you may achieve this by first setting a variable to a filter that converts the content of your tiddler-tag field into a list :

<$set name=mytags filter="[enlist{!!tiddler-tag}]">
<$action-sendmessage $message="tm-new-tiddler"
title=<<TIDDLER-TITLE>>
text=<<TIDDLER-TEMPLATE>>
tags=<<mytags>>/>
</$set>

Note the use of the enlist operator to transform a string into a list. 5.1.23 just introduced the enlist-input operator, which is handy in situations where your initial string comes from a previous filter expression.

Cheers,
-- Xavier


--
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/b46bc104-7460-4e0a-9463-b7f90ecc6b85n%40googlegroups.com.

vinvi...@gmail.com

ongelezen,
2 jan 2021, 12:01:1402-01-2021
aan TiddlyWiki
Thank you Xavier,

Can you tell me how to paste this piece of code into the existing code? 
For some reason I am not getting it working.

Op zaterdag 2 januari 2021 om 17:19:56 UTC+1 schreef Xavier:

Xavier Cazin

ongelezen,
2 jan 2021, 13:30:1302-01-2021
aan tiddl...@googlegroups.com
Hi,

Sorry I overlooked the need to interpret the currentTiddler variable. In this situation, you need to read your field as a filter rather than a list. Two main ways of doing that:
  1. Either you put your button code in a macro so that the $(currentTiddler)$ construct is actually replaced by the title of the current tiddler. Then you can use the subfilter operator, as in :
    \define mybutton()

  1. <$button type="button" class=<<BUTTON-COLOR+SIZE>>>
  1. <$set name=mytags filter="[subfilter{!!tiddler-tag}]">

  1. <$action-sendmessage $message="tm-new-tiddler"
    title=<<TIDDLER-TITLE>>
    text=<<TIDDLER-TEMPLATE>>
    tags=<<mytags>>/>
    </$set>
  1. <span style=<<BUTTON-TEXT-COLOR>>><<BUTTON-NAME>></span>
    </$button>
  1. \end
    <<mybutton>>
  2. Or you can just replace [[$(currentTiddler)$]] with [<currentTiddler>] in your field content.  Like so :
    <$set name=mytags filter="[subfilter{!!tiddler-tag}]">

  1. <$action-sendmessage $message="tm-new-tiddler"
    title=<<TIDDLER-TITLE>>
    text=<<TIDDLER-TEMPLATE>>
    tags=<<mytags>>/>
    </$set>
Cheers,
-- Xavier


vinvi...@gmail.com

ongelezen,
2 jan 2021, 15:43:4202-01-2021
aan TiddlyWiki
Thank you!

Op zaterdag 2 januari 2021 om 19:30:13 UTC+1 schreef Xavier:
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten