[TW5] How to put variable to {{}} ?

141 views
Skip to first unread message

sini-Kit

unread,
Jan 22, 2016, 6:05:05 AM1/22/16
to TiddlyWiki
Hi! I have a very simple list filter   <$list filter="[list[$:/StoryList!!list]limit[1]]" variable="name"> {{<name>!!selpar}}   </$list>

is it possible to put variable="name" to {{}} ? field selpar contains macros selpar:<<filpar size>> and  $view or $transclude don't work.

sini-Kit

unread,
Jan 22, 2016, 7:06:30 AM1/22/16
to TiddlyWiki
I find only this

\define selPar()
{{$(name)$!!selpar}}  
\end

<$list filter="[list[$:/StoryList!!list]limit[1]]" variable="nazvanie">
<$set name="name"  value=<<nazvanie>> >
<<selPar>>
</$set>
</$list>





пятница, 22 января 2016 г., 14:05:05 UTC+3 пользователь sini-Kit написал:

Tobias Beer

unread,
Jan 22, 2016, 7:15:53 AM1/22/16
to TiddlyWiki
Hi sini-Kit,

Why not just do this:

<$list filter="[list[$:/StoryList!!list]limit[1]]" variable="nazvanie">
<$transclude tiddler=<<nazvanie>> field="setpar"/>
</$list>

or just:

<$list filter="[list[$:/StoryList!!list]limit[1]]"
>
{{!!setpar}}
</$list>

?

When wishing to evaluate attributes, there's a good chance you always need to resort to using widgets, incl. the macrocall widget and perhaps some helper macros if that isn't enough already.

Best wishes,

Tobias. 

Eric Shulman

unread,
Jan 22, 2016, 7:20:33 AM1/22/16
to TiddlyWiki
On Friday, January 22, 2016 at 4:06:30 AM UTC-8, sini-Kit wrote:
I find only this

\define selPar()
{{$(name)$!!selpar}}  
\end

<$list filter="[list[$:/StoryList!!list]limit[1]]" variable="nazvanie">
<$set name="name"  value=<<nazvanie>> >
<<selPar>>
</$set>
</$list>

TiddlyWiki uses the macro mechanism to construct wiki syntax from text parts and pieces.  To generate a transclusion that is assembled from a value stored in a variable, you need to use a macro as you have correctly done above.  Note that there is no need to use an intermediate variable (e.g., "name"), and you can use the "one line" syntax for definining the macro.... Thus, you can simplify your code to:

\define selPar() {{$(nazvanie)$!!selpar}}  
<$list filter="[list[$:/StoryList!!list]limit[1]]" variable="nazvanie">
<<selPar>>
</$list>

-e

Eric Shulman

unread,
Jan 22, 2016, 7:26:13 AM1/22/16
to TiddlyWiki
On Friday, January 22, 2016 at 4:20:33 AM UTC-8, Eric Shulman wrote:
TiddlyWiki uses the macro mechanism to construct wiki syntax from text parts and pieces.  To generate a transclusion that is assembled from a value stored in a variable, you need to use a macro as you have correctly done above.

As Tobias noted in another post, because you are generating a transclusion, you could use the <$transclude> widget instead of the {{...}} syntax, and that would allow you to directly use variables as widget parameters.  As Tobias also noted, you don't even need to use a separate variable, since the <$list> widget automatically sets the "currentTiddler" context, so the simplified syntax for transclusion of a fieldname can be used, like this:

<$list filter="...">{{!!fieldname}}</$list>

-e

sini-Kit

unread,
Jan 23, 2016, 9:07:19 AM1/23/16
to TiddlyWiki
Thank you Tobias, and Eric. But all your variants don't work in my wiki. You can try them  here http://novye-podarki.ru/empty26_.html#Figures  my define work on left panel


I think your variants don't work because tiddler _header http://novye-podarki.ru/empty26_.html#%24%3A%2F_header don't understand what tiddler is current

пятница, 22 января 2016 г., 15:15:53 UTC+3 пользователь Tobias Beer написал:

Tobias Beer

unread,
Jan 23, 2016, 10:10:08 AM1/23/16
to TiddlyWiki
Hi sini-Kit,

Try to debug your code step by step.
For example, if I just do this:

{{{ [list[$:/StoryList!!list]] }}}

...then I get nothing.

Perhaps you try to explain from the very beginning
  • what you actually want to do and
  • how you imagined of achieving it
...not in terms of solution (macro this and that) but in terms of concept (I want to show foo at bar).

Best wishes,

Tobias.

sini-Kit

unread,
Jan 23, 2016, 12:38:09 PM1/23/16
to TiddlyWiki
Tobias, I solve my problem, but not in that way I wanted.
 I have a problem with "current tiddler" again. In zoomin view other tiddlers don't know what tiddler is current. if I make tiddler with   text <<currentTiddler>> , and put tag $:/tags/TopLeftBar nothing will appear in  TopLeftBar , because TopLeftBar don't know what tiddler is current .


суббота, 23 января 2016 г., 18:10:08 UTC+3 пользователь Tobias Beer написал:

Tobias Beer

unread,
Jan 23, 2016, 2:11:34 PM1/23/16
to TiddlyWiki
Hi sini-Kit,
 
 I have a problem with "current tiddler" again. In zoomin view other tiddlers don't know what tiddler is current. if I make tiddler with   text <<currentTiddler>> , and put tag $:/tags/TopLeftBar nothing will appear in  TopLeftBar , because TopLeftBar don't know what tiddler is current .

I thought that's why you were using the StoryList tiddler... so as to read that "currentTiddler" ...which in your case appears to always be one at a time.

Best wishes,

Tobias.

Eric Shulman

unread,
Jan 23, 2016, 5:45:50 PM1/23/16
to TiddlyWiki
On Saturday, January 23, 2016 at 9:38:09 AM UTC-8, sini-Kit wrote:
 I have a problem with "current tiddler" again. In zoomin view other tiddlers don't know what tiddler is current. if I make tiddler with   text <<currentTiddler>> , and put tag $:/tags/TopLeftBar nothing will appear in  TopLeftBar , because TopLeftBar don't know what tiddler is current .

I think you may have some confusion about what "current" tiddler the <<currentTiddler>> variable refers to.

It is not about which tiddler is "currently viewed by the user"... rather, the "current" tiddler is the context in which the macro is being processed and rendered by the TWCore.  Thus, if I put <<currentTiddler>> into a tiddler named "Foo", and then view that tiddler, the value of <<currentTiddler>> if "Foo", regardless of which other tiddlers are being displayed in the story.  Tagging that tiddler with $:/tags/TopLeftBar automatically transcludes it into the $:/core/ui/PageTemplate/topleftbar, which makes that tiddler the "currentTiddler" in the *rendering* process.  In your example (putting <<currentTiddler>> into a tiddler tagged with $:/tags/TopLeftBar), it *should* have displayed "$:/core/ui/PageTemplate/topleftbar" in the top left of your document.  However, you report that "nothing" appears there, which is not the results I would expect.

In any case, using <<currentTiddler>> won't get you what you want, i.e. the name of the tiddler currently being displayed in the StoryRiver.  For that, try using {{$:/HistoryList!!current-tiddler}}, which is automatically updated whenever you open/view a tiddler (i.e., by clicking a tiddler link).

However, there is one relatively small issue with HistoryList!!current-tiddler... it is not updated when you close a tiddler (because it's *only* closing the tiddler, and no navigation to another tiddler occurs at that time).  One way to avoid this is to hide the 'close tiddler' in the ViewToolbar control panel settings, so that the user can't actually close open tiddlers.  Since you are using zoom-in mode to display tiddlers one-at-a-time, the user can simply navigate to another tiddler, with the *appearance* that the first tiddler is "closed" (even though it's really still in the StoryRiver... just hidden at the moment).

hope this helps,

enjoy,
-e

sini-Kit

unread,
Jan 24, 2016, 10:05:12 AM1/24/16
to TiddlyWiki
Thank you Eric! I don't know about  {{$:/HistoryList!!current-tiddler}}.  I have one question. Why if I delete temp tiddler http://novye-podarki.ru/empty26_.html#%24%3A%2Ftemp%2F_HideStoryList with my lists, I have to check checboxes 3 times to make it work here  http://novye-podarki.ru/empty26_.html#Figures ?

It happens because in first click fields are not ready?  here is my macros  http://novye-podarki.ru/empty26_.html#%24%3A%2F_macros%2Ffilpar

воскресенье, 24 января 2016 г., 1:45:50 UTC+3 пользователь Eric Shulman написал:
Reply all
Reply to author
Forward
0 new messages