WikifyPlugin question

30 views
Skip to first unread message

axelm

unread,
Dec 7, 2011, 10:03:16 AM12/7/11
to tiddl...@googlegroups.com
Hello all,

I have this in a tiddler and it works fine:

<<wikify "%0" tdptask0>>

However, if the field does not exist, it produces this text:

tdptask0

How can I make it not show anything, if the field does not exist?

Not a big deal, but just not pretty.

thank you for any help,

axelm

Måns

unread,
Dec 7, 2011, 12:46:35 PM12/7/11
to TiddlyWiki
Hi axelm

> <<wikify "%0" tdptask0>>
>
> However, if the field does not exist, it produces this text:
>
> tdptask0
>
> How can I make it not show anything, if the field does not exist?

I've got the same problem. A while back I tried different things - and
I made a fallback for tiddler data [1]:

<<wikify %0 {{tiddler.data("datatitle","data is missing")}}>>

This is why I'd expect this to work:
<<wikify %0 {{store.getValue("fieldtitle","fieldvalue is missing")}}>>

It doesn't ?!?!... - I can't figure out what workaround could produce
a fallback...

[1] http://tiddlywiki.abego-software.de/#DataTiddlerPlugin

Cheers Måns Mårtensson

colmjude

unread,
Dec 8, 2011, 11:32:43 AM12/8/11
to TiddlyWiki
Any chance you can share or point to the WikifyPlugin? Might allow
more people to help fix your issue.

Many eyes make all bugs shallow and all that... :)

Cheers,

Colm

axelm

unread,
Dec 8, 2011, 12:49:02 PM12/8/11
to tiddl...@googlegroups.com
colmjude, here is the link to the plugin:

http://www.tiddlytools.com/#WikifyPlugin

axelm

Eric Shulman

unread,
Dec 8, 2011, 1:58:59 PM12/8/11
to TiddlyWiki

On Dec 7, 9:46 am, Måns <humam...@gmail.com> wrote:
> Hi axelm
>
> > <<wikify "%0" tdptask0>>
>
> > However, if the field does not exist, it produces this text:
>
> > tdptask0
>
> > How can I make it not show anything, if the field does not exist?

I will add an option to the plugin that will allow you to suppress the
field name displayed as output when the field isn't present.

> I've got the same problem. A while back I tried different things - and
> I made a fallback for tiddler data [1]:
>

> <<wikify %0 {{store.getValue("fieldtitle","fieldvalue is missing")}}>>
>
> It doesn't ?!?!... - I can't figure out what workaround could produce
> a fallback...

You are missing an argument to the getValue() function. You need to
pass both the tiddler *title* and the *fieldname* (as well as the
fallback default value). Thus:

<<wikify %0 {{store.getValue("tiddlertitle","fieldtitle","fieldvalue
is missing")}}>>

enjoy,
-e

Måns

unread,
Dec 8, 2011, 3:34:00 PM12/8/11
to TiddlyWiki
Hi Eric

> You need to pass both the tiddler *title* and the *fieldname* (as well as the fallback default value).  Thus:
>
> <<wikify %0 {{store.getValue("tiddlertitle","fieldtitle","fieldvalue is missing")}}>>

I tried:
[[StoreGetValueFallback]
<<tiddler StoreGetValueFallback##wikify with:{{tiddler.title}}>>/%
!wikify
<<wikify %0 {{store.getValue("$1","fieldtitle","fieldvalue is
missing")}}>>
!end %/

- to no avail.
What am I doing wrong this time?

Cheers Måns Mårtensson

Eric Shulman

unread,
Dec 8, 2011, 4:51:21 PM12/8/11
to TiddlyWiki
> > <<wikify %0 {{store.getValue("tiddlertitle","fieldtitle","fieldvalue is missing")}}>>

Actually, it turns out that getValue(...) only takes 2 arguments, and
does *not* support passing a 'fallback' value for when the field is
not present. You *can* still provide a fallback value, but the code
is a bit different:

{{store.getValue("tiddlertitle","fieldtitle")||"fieldvalue is
missing"}}

This will invoke getValue() and then, if it returns a NULL, it will
fallback to using the text following the "OR" (||) separator.

Also note that there was no reason to use the "section transclusion"
trick to pass the tiddler title. You can reference "tiddler.title"
directly within the evaluated parameter in the <<wikify>> macro.
Thus:

<<wikify %0 {{store.getValue(tiddler.title,"fieldtitle")||"fieldvalue
is missing"}}>>

-e

Måns

unread,
Dec 8, 2011, 5:11:48 PM12/8/11
to TiddlyWiki
Hi Eric

> {{store.getValue("tiddlertitle","fieldtitle")||"fieldvalue is missing"}}

Great :-) I've been asking for this so many times that I've lost track
of how many....
Eric are you the *only* TW-supporting genius who can provide this kind
of information??

> This will invoke getValue() and then, if it returns a NULL, it will fallback to using the text following the "OR" (||) separator.

Ok - That makes sense - Thanks for the explanation.

> Also note that there was no reason to use the "section transclusion" trick to pass the tiddler title.  You can reference "tiddler.title"
> directly within the evaluated parameter in the <<wikify>> macro.
> Thus:
> <<wikify %0 {{store.getValue(tiddler.title,"fieldtitle")||"fieldvalue is missing"}}>>

I actually *did* try that as my first attempt - the transclusion is
just an example of one of the "workaround-methods" I use when I'm
unsure if something is working outside a script or a fET... (I often
try to use things I find in scripts or fETs in transclusions..)

Thanks for resolving this mystery that has been haunting me for at
least a year now :-)

Cheers Måns Mårtensson

Reply all
Reply to author
Forward
0 new messages