Transcluding a field value, one more time

96 views
Skip to first unread message

Steven Schneider

unread,
Jul 24, 2017, 8:53:03 PM7/24/17
to TiddlyWiki
Hi,

Can't quite get this right....

In http://sunypoly-schedule-explorer.tiddlyspot.com/ the current default tiddler is a macro that generates a link to tiddlers based on values of a field in a set of tiddlers. So, in this case, a schedule, <$macrocall $name="show-field" this-field="room"/> --  all possible values for room are collected and put in a button; clicking on the button creates a tiddler that is supposed to be room-{{!!room}}.  It's close -- I'm getting exactly that: room-{{!!room}}. I'd like to transclude the value of room into the tiddler title, of course. 

Any help, much appreciated. Thanks!

(I find transcluding field values rather difficult, and I seem to do a lot of it these days...)

//steve.



\define getFieldValue() {{!!$(this-field)$}}


\define makeTiddlerName() $(this-field)$-$(this-value)$


\define show-field($this-field$)


<$list filter="[tag[schedule-elements]each[$this-field$]sort[$this-field$]]">
currentTiddler: <$link><<currentTiddler>></$link><br>
<$vars this-field=$this-field$ >
<$set name=this-value value=<<getFieldValue>>>
1 this-field: <<this-field>><br>
2 this-value: <<this-value>><br>
3 makeTiddlerName: <<makeTiddlerName>><br>
<$button>
<<makeTiddlerName>>
<$action-setfield $tiddler=<<makeTiddlerName>> field-name=<<this-field>> field-value=<<getFieldValue>> role="field-value" orig-tag="schedule-elements"/>
<$action-navigate $to=<<makeTiddlerName>>/>
</$button><br>
\end

<$macrocall $name="show-field" this-field="room"/>


Mat

unread,
Jul 24, 2017, 10:07:28 PM7/24/17
to TiddlyWiki
Hi Steve! 
That doesn't look correct to me;

\define show-field($this-field$)

what
's this?


<$list filter="[tag[schedule-elements]each[$this-field$]sort[$this-field$]]">


Should probably not be empty rows there and the macro parameter should probably not be with dollars.


<:-)

Steven Schneider

unread,
Jul 25, 2017, 1:12:51 PM7/25/17
to TiddlyWiki
Hey, thanks. I (1) resaved my tiddlyspot, so this code is in the default tiddler and (2) made the changes mat suggested. But I am still not able to transclude the value of a field into the name of a tiddler. 

in these lines


<<makeTiddlerName>>
<$action-setfield $tiddler=<<makeTiddlerName>> field-name=<<this-field>> field-value=<<this-value>> role="field-value" orig-tag="schedule-elements"/>
<$action-navigate $to=<<makeTiddlerName>>/>

<<makeTiddlerName>> , which is \define makeTiddlerName() $(this-field)$-$(this-value)$, works on its own as <<makeTiddlerName>> but doesn't work as a transcluded link in $action-setfield or $action-navigate


Here's all the revised code

\define getFieldValue() {{!!$(this-field)$}}

\define makeTiddlerName() $(this-field)$-$(this-value)$

\define show-field(this-field)
this-field=$this-field$<br><hr>
<$vars this-field=$this-field$ >
<$list filter="[tag[schedule-elements]each<this-field>sort<this-field>]">
0 currentTiddler: <$link><<currentTiddler>></$link><br>
<$set name=this-value value=<<getFieldValue>>>
1 this-field: <<this-field>><br>
2 this-value: <<this-value>><br>
3 makeTiddlerName: <<makeTiddlerName>><br>
4 <$button>
<<makeTiddlerName>>
<$action-setfield $tiddler=<<makeTiddlerName>> field-name=<<this-field>> field-value=<<this-value>> role="field-value" orig-tag="schedule-elements"/>
<$action-navigate $to=<<makeTiddlerName>>/>
</$button><hr>
\end

<$macrocall $name="show-field" this-field="credits"/>

Mark S.

unread,
Jul 25, 2017, 1:56:48 PM7/25/17
to TiddlyWiki
Try this

\define show-field(this-field)
this-field=$this-field$<br><hr>
<$vars this-field=$this-field$ >
<$list filter="[tag[schedule-elements]each<this-field>sort<this-field>]">
0 currentTiddler: <$link><<currentTiddler>></$link><br>
<$set name=this-value value=<<getFieldValue>>>
<$wikify name=newtid text="<<makeTiddlerName>>">

1 this-field: <<this-field>><br>
2 this-value: <<this-value>><br>
3 makeTiddlerName: <<newtid>><br>
4 <$button>
<<newtid>>
<$action-setfield $tiddler=<<newtid>> field-name=<<this-field>> field-value=<<this-value>> role="field-value" orig-tag="schedule-elements"/>
<$action-navigate $to=<<newtid>>/>
</
$button></$wikify></$set><hr>
\end


Used wikify widget to force the macro to be interpreted before use. Also added in missing end tag </$set>

Good luck,
Mark

Steven Schneider

unread,
Jul 25, 2017, 7:46:58 PM7/25/17
to TiddlyWiki
Mark, thanks. That works.

<$wikify> was an answer to a question I had a few months ago, too -- Thomas I think used it in one of his macros. I still don't quite get what it does, but it seems to do the trick sometimes.


//steve.
Reply all
Reply to author
Forward
0 new messages