Using currentTiddler name in a filter

207 views
Skip to first unread message

Fidel N

unread,
Oct 15, 2016, 6:37:49 AM10/15/16
to TiddlyWiki
Hi:
I have read and tried many solutions, most of them were reportedly working, but I cant manage to make this work for me :(

My current code is this one:

Macro definition for testing:

\define current_title()
Miscelaneous
\end



Defining the variable value also for testing:

<$set name="myVariable" value=<<currentTiddler>> >
<$text text=<
<myVariable>>/>
</$set>


Test the variable, renders OK (currentTiddler title):
<<myVariable>>



And now, doesnt matter how I try, I cant manage to filter with the variable value:
<$list filter="[tag{{!!myVariable}}]">
<$list filter="[tag
<myVariable>]">
<$list filter="[tag<
<myVariable>>]">
<$list filter="[tag{!!myVariable}]">


The only thing I managed to work is:

<$list filter="[tag<current_title>]">


But for this I had to manually insert the tiddler name within the macro...

What got me to ask here is that I can use the macro but no variable seems to work even though they render OK outside the list....

What do you guys think is happening??

Riz

unread,
Oct 15, 2016, 7:43:31 AM10/15/16
to TiddlyWiki
Just clarifying. Your list filters are declared before the closing of the set widget, right?

BJ

unread,
Oct 15, 2016, 7:47:31 AM10/15/16
to TiddlyWiki
Hi Fidel,

the syntax is like


<$set name="myVariable" value=<<currentTiddler>>>
<$list filter="[search<myVariable>]">
<$text text={{!!title}}/>
</$list>
</$set>

hope this helps
BJ

I see that your 'list' widgets do not have a closing '/' so it would be

Riz

unread,
Oct 15, 2016, 7:49:42 AM10/15/16
to TiddlyWiki

Assuming what you want is a list of tiddlers tagged with the title of current tiddler, this code will work.

<$set name="myVar" value=<<currentTiddler>>>

<$list filter="[tag<myVar>]"/>

</$set>


Fidel N

unread,
Oct 15, 2016, 1:48:37 PM10/15/16
to TiddlyWiki
Your words "tagged with the title of current tiddler" resonated in my brain until I realized that the reason why it was not working properly is because while I was editing (and checking the rendered tiddler at the same time) the tiddler is named "Draft of ..." and not same as the tag..... I probably had it properly coded like 100 times today but it would never show because of the tiddler name!!!!

Thank you BJ and Riz for helping me realize this, what a noobs mistake!!!

PMario

unread,
Oct 15, 2016, 2:45:31 PM10/15/16
to TiddlyWiki
On Saturday, October 15, 2016 at 7:48:37 PM UTC+2, Fidel N wrote:
Your words "tagged with the title of current tiddler" resonated in my brain until I realized that the reason why it was not working properly is because while I was editing (and checking the rendered tiddler at the same time) the tiddler is named "Draft of ..."

... ouch! ... But you are not alone :))

-m

Steven Schneider

unread,
Oct 17, 2016, 8:35:17 PM10/17/16
to TiddlyWiki
Maybe I'm missing something, but wouldn't this work to filter tiddlers tagged with the current tiddler:

<$list filter="[tag{!!title}]"> or <$list filter="[tag<currentTiddler>]"> ? 

Really, what I think I'm asking is what is the value / advantage of using s <$set> command? I can think of one: having the variable available within a future <$list> function, when <<currentTiddler>> has taken on another vaue. Are there others?





//steve.

PMario

unread,
Oct 18, 2016, 4:29:14 AM10/18/16
to TiddlyWiki
Hi Steve,

The point here is, that the following code produces different output, depending on edit or view mode. eg:

 - create 2 tiddlers named "a" and "b"
 - tag them "test"
 - create a tiddler named: test
 - save it
 - open it and copy the following code into it
 - open Preview Mode
 - save the tiddler again

you should see a difference. Code for tiddler "test":


```
<$list filter="[tag{!!title}]"><<currentTiddler>>, </$list>
```
<$list filter="[tag{!!title}]"><<currentTiddler>>, </$list>

```
<$list filter="[tag<currentTiddler>]"><<currentTiddler>>, </$list>
```
<$list filter="[tag<currentTiddler>]"><<currentTiddler>>, </$list>

```
<$list filter="[tag[test]]"><<currentTiddler>>, </$list>
```
 <$list filter="[tag[test]]"><<currentTiddler>>, </$list>



have fun!
mario

PMario

unread,
Oct 18, 2016, 4:32:37 AM10/18/16
to TiddlyWiki
tiddlers.json for drag and drop import :)
-m
tiddlers(8).json

stevesuny

unread,
Oct 18, 2016, 9:21:46 AM10/18/16
to TiddlyWiki
Thanks, Mario! These are the kinds of tutorials / explanations I'm trying to build for {{DesignWrite}}. So, at the risk of belaboring the point -- and with apologies to those for whom this it too fine-grained. I've numbered your three code snippets below (1) (2) (3),  added (4). and

 I see that in edit mode, (1) and (2) and (4) produce no output, given that  {{!!title}} and <<currentTiddler>> have both taken the value of Draft of 'test', while in view mode (1) (2)  (3) and (4) produce identical output.

This yields three questions for me:

<A> What are the differences between  using a specified transcluded field in a filter, as in (1), and using a macro <<currentTiddler>> in a filter as in (2)? In what circumstances is (1) preferred over (2) and vice-versa?

<B> What is the value of using <$set> as in(4)?

<C> What is the use case for hard-coding rather than transcluding a filter list, as in (3)?

Thanks!

//steve.



On Tuesday, October 18, 2016 at 4:29:14 AM UTC-4, PMario wrote:
Hi Steve,

The point here is, that the following code produces different output, depending on edit or view mode. eg:

 - create 2 tiddlers named "a" and "b"
 - tag them "test"
 - create a tiddler named: test
 - save it
 - open it and copy the following code into it
 - open Preview Mode
 - save the tiddler again

you should see a difference. Code for tiddler "test":


```
(1) <$list filter="[tag{!!title}]"><<currentTiddler>>, </$list>
```
<$list filter="[tag{!!title}]"><<currentTiddler>>, </$list>

```
(2) <$list filter="[tag<currentTiddler>]"><<currentTiddler>>, </$list>

```
<$list filter="[tag<currentTiddler>]"><<currentTiddler>>, </$list>

```
(3) <$list filter="[tag[test]]"><<currentTiddler>>, </$list>

```
 <$list filter="[tag[test]]"><<currentTiddler>>, </$list>

```
(4)
<$list filter="[tag{!!title}]">
<$set name="testVar" value=<<currentTiddler>>>
<<testVar>>,
</$set></$list>
```
<$list filter="[tag
{!!title}]">
<$set name="testVar" value=<<currentTiddler>>>
<<testVar>>,
</$set></$list>


have fun!
mario
Reply all
Reply to author
Forward
0 new messages