> <<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
Many eyes make all bugs shallow and all that... :)
Cheers,
Colm
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
> 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
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
> {{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