Hello,
I have created a JSON tiddler attached to import into tiddlywiki.com to illustrate my issue but the example code is:
\define exportJsonButton(exportFilter:"[!is[system]sort[title]]",baseFilename:"JSONexport")
<$set name="extension" value=".json">
<$button class="tc-btn-invisible" dragFilter=<<__exportFilter__>> tooltip="Click button to download a JSON archive or drag to another wiki to copy.">
{{$:/core/images/export-button}}
<$action-sendmessage $message="tm-download-file" $param="$:/core/templates/exporters/JsonFile" exportFilter=<<__exportFilter__>> filename=<<exportButtonFilename """$baseFilename$""">>/>
</$button>
</$set>
\end
\function currentSelection() [<currentSelectionStateTid>get[text]]
\function currentSelectionStateTid() [[tm-download-file Issue]get[currentSelectionTiddler]]
<$select tiddler={{tm-download-file Issue!!currentSelectionTiddler}}>
<option></option>
<$list filter="[tags[]]">
<option><$view field='title'/></option>
</$list>
</$select>
Current selection: <<currentSelection>>
Current selection state tiddler: {{{[<currentSelectionStateTid>]}}}
selection state tiddler is hardcoded: Works for both click and drag: <$transclude $variable="exportJsonButton" exportFilter="""[search:title,tags{$:/state/currentSelection}]""" baseFilename=<<currentSelection>> />
Attempt to make selection state tiddler configurable in field ``currentSelectionTiddler``. Works for drag but click matches all tiddlers: <$transclude $variable="exportJsonButton" exportFilter="""[search:title,tags<currentSelection>]""" baseFilename=<<currentSelection>> />
I was trying to use a function to abstract a state tiddler location so that you can define the location of the state tidder in a field of a config tiddler and use that info from the state tiddler in the filter fed to the tm-download-file message.
For some reason the exportFilter="""[search:title,tags<currentSelection>]"""
does not work for tm-download-file and matches on all tiddlers but if you “hardcode” the state location with exportFilter="""[search:title,tags{$:/state/currentSelection}]"""
it properly matches tiddlers with tags and titles containing the words contained in $:/state/currentSelection.
The both filters work just fine when used in the dragFilter for the button widget.
In the end, I had to “hardcode” in the state tiddler and it seems that tm-download-file message is broken with functions. Is this supposed to be how functions are used? Does anyone know of a workaround?
Thanks,
/Mike
tm-download-file Issue.json (1.7 KB)