Discussion:
[tw5] [TW5] Clarification of lists with current tiddler
(too old to reply)
TonyM
2018-04-22 02:29:41 UTC
Permalink
Folks,

Perhaps this answer is already in my mind but I wish to state it succinctly
and see if a more experienced TiddlyWiki Fan can state a simple answer.
Question contained within the examples

*Case 1. Standard behaviour and use*
<$list filter="a filter">
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> changes with each title in the <$list
Can no longer access the Calling Tiddlers values with {{!!fieldname}}
references including {{!!title}}
</$list>

*Case 2. Retain access to the calling tiddler *
<$list filter="a filter" variable=mytitle>
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> will not change, ie uses the tiddlers values where the
list is called.
Refer to title as <<mytitle>>
</$list>

*Note:*
In the above two cases the field references of the form {{!!fieldname}}
change from the calling to the listed tiddler

*Question*
In the cases above what is the* best way t*o access the values of the
calling or listed tiddlers fields?

Case 1. Reference the fields of tiddler who's title is available in the
calling tiddler
Case 2. Reference the fields of tiddler who's title is available in the
<<mytitle>>

Of course an added complication is when you want to use the title or field
name and value in widgets, filters, variables within these <$lists we need
to use alternate ways to reference said field values. Thus it It gets
awfully complex quickly and it is taking a lot of time for me to deeply
learn this.

What do I need to know so I do not have to research how every time to use
the correct reference method?


Here is a method I use that others may want to know.


*My Special use case of a variable I do not use for logical (display or
dont display contents)*
<$list filter="a filter" variable=null>
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> will not change, ie uses the tiddlers values where the
<$list is called.
Useful for cases where the filter is simply a test as to determine if the
content is displayed,
Tend not to use <<null>>
Can add to the filter limit[1] if the filter can result in more than one
value.
</$list>
You can nest multiple lists all with the variable null
A Common filter seems to be "[is[current]<fieldname>] -[[no]]" to display
if fieldname has a value of "yes"

Thanks in advance
Tony
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b6f19a69-9775-4975-b9eb-7177fed8ce27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2018-04-22 08:24:28 UTC
Permalink
I don't think there is a 'best way'. There isn't any convenient shorthand
for {{!!fieldname}} for anything other than the tiddler listed in
currentTiddler. If you have to reference both the containing tiddler and
the current tiddler in the list a lot than you can make a macro like this

\define containingTiddler(field) {{$(containingTiddler)$!!$field$}}


and then in you could do this (example for tiddlywiki.com):

<$set name=containingTiddler value=<<currentTiddler>>>
<$list filter='[tag[HelloThere]]'>
<<containingTiddler title>> - {{!!title}}<br>
</$list>
</$set>


so inside the $list you use <<containingTiddler fieldname>> instead of
{{!!fieldname}} when you want the containing tiddler.

It is far from perfect because you have to make the set widget outside the
loop each time (or once in the tiddler, it could contain everything else in
the tiddler). If you put the macro in a tiddler tagged with $:/tags/Macro
you can have that define once for your whole wiki.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/eacb41a8-912b-4591-b8d0-382eafff376c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-04-22 13:36:39 UTC
Permalink
Thanks Jed,

You have done two things for me, provided a resonable solution and confirmed I was not imagining things.

With respect to all the greatness of tiddlywiki this is to me a gap that must be filled, because I for one, and I suspect many others, expected a more direct approach to exist, so its absence was screwing with my mind, it took months for me to be able to even ask this simple question and in the mean time I have run down many rabit holes for many hours not to mention, once desperate, posting in the forum wondering why the solutions were never strait forward.

Unfortunatly intelegent people expect or assume that such simple requirements can already be satisfied in a consistent and comprehencive way in any sophisticated tool.

I am comming to expect I will find a few more as my expertise grows but such gaps really make the learning curve much steeper. I expect this issue alone complicates a lot of user coding, but is also forcing solutions to be convoluted. It is insidious because it is almost imposible to craft search keywords for something that is missing.

I would like to be corrected if I am wrong about this but I would prefer it to be fixed.

Thank you and
Regards
Tony
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/31c653b5-ebee-4c62-81f7-9bdd539f2d12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
BJ
2018-04-22 12:19:02 UTC
Permalink
may be we could have a 'pop' widget

http://bjhacks.tiddlyspot.com/#pop%20example
Post by TonyM
Folks,
Perhaps this answer is already in my mind but I wish to state it
succinctly and see if a more experienced TiddlyWiki Fan can state a simple
answer. Question contained within the examples
*Case 1. Standard behaviour and use*
<$list filter="a filter">
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> changes with each title in the <$list
Can no longer access the Calling Tiddlers values with {{!!fieldname}}
references including {{!!title}}
</$list>
*Case 2. Retain access to the calling tiddler *
<$list filter="a filter" variable=mytitle>
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> will not change, ie uses the tiddlers values where the
list is called.
Refer to title as <<mytitle>>
</$list>
*Note:*
In the above two cases the field references of the form {{!!fieldname}}
change from the calling to the listed tiddler
*Question*
In the cases above what is the* best way t*o access the values of the
calling or listed tiddlers fields?
Case 1. Reference the fields of tiddler who's title is available in the
calling tiddler
Case 2. Reference the fields of tiddler who's title is available in the
<<mytitle>>
Of course an added complication is when you want to use the title or field
name and value in widgets, filters, variables within these <$lists we need
to use alternate ways to reference said field values. Thus it It gets
awfully complex quickly and it is taking a lot of time for me to deeply
learn this.
What do I need to know so I do not have to research how every time to use
the correct reference method?
Here is a method I use that others may want to know.
*My Special use case of a variable I do not use for logical (display or
dont display contents)*
<$list filter="a filter" variable=null>
Allows {{!!fieldname}} references including {{!!title}} and
<<currentTiddler>> will not change, ie uses the tiddlers values where the
<$list is called.
Useful for cases where the filter is simply a test as to determine if the
content is displayed,
Tend not to use <<null>>
Can add to the filter limit[1] if the filter can result in more than one
value.
</$list>
You can nest multiple lists all with the variable null
A Common filter seems to be "[is[current]<fieldname>] -[[no]]" to display
if fieldname has a value of "yes"
Thanks in advance
Tony
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c0ced6d6-a117-4d69-b129-4f822f153e3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2018-04-22 14:38:40 UTC
Permalink
It may be possible to add something like this to the core, but it wouldn't
be straight forward. The biggest problem is determining where the outer
containing tiddler is, like if you have multiple lists inside each other
how do you determine which containing tiddler you want? It would have to be
an nth parent sort of thing and I am not certain that would be any simpler
to use than what we have now.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b2617d5b-b4ac-4217-a07d-835bea9531a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-04-23 00:27:34 UTC
Permalink
Jed,

It is true that accessing the nth tiddlers info your be tricky, but just
being able to access the 0th would be enough to make big changes. By this I
am referring to the tiddler in the face of the user. The logical place they
are at, the item listed in the story. This makes me think perhaps we can
come at it from another approach.

Personally, It is not if it is core or not, just that a strait forward
system exists to reference all fields in the 0th, N-1 and N

If I understand BJ's suggestion its like the push and pop idea where the
list pushes items onto a list and pop steps back one item on the list.
Using stack metaphors.

As far as I can see although this may very well be helpful, the key
references will usually be the 0th, the Nth and the N-1th if you wish to
start referencing this such as N-2th or 5th etc... in another iteration, to
make the code understandable, then it is more reasonable to start using
additional variables etc...

Taking BJ's idea to push and pop his example pops to one layer before and
that happens to be the 0th layer. This is a great example of the N-1th,
note all we *need* is a way to reference the 0th without popping (imagine
we are 3-4 deep)

So on further consideration what if; as Jed said we had a "convenient
shorthand"
An enhancement to the <$list widget perhaps using a parameter, would allow
us to request a push (of the references) of the containing tiddler to a
stack, and then where ever you are in the nested lists you can either
reference 0th or N-1th field values and/or use pop (one or more or N
times). In reality a push need only be the storage of containing
tiddler-title, if subsequently we have a way of referencing the fields and
values from anywhere of that tiddlername. Basically the :N is replaced with
the appropriate tiddler title.

As an example (not literal) {{:-1!!fieldname}} {{:-N!!fieldname}}
{{:0!!fieldname:0}} including [[:N!!fieldname]] [[pretty|:N!!fieldname]]
[[pretty|:0!!fieldname]] especially [[pretty|:0!!title]]

Of course we could perhaps call these "relative tiddler names".

Alternatively we store the tiddlersname by name eg <$list push="parent"
make the tiddlertitle calling this list be stored as parent. Then you can
reference {{:parent!!fieldname}}

Perhaps some of Mario's uni-link tech could effectively provide dynamic
relative aliases.

Regards
Tony
Post by Jed Carty
It may be possible to add something like this to the core, but it wouldn't
be straight forward. The biggest problem is determining where the outer
containing tiddler is, like if you have multiple lists inside each other
how do you determine which containing tiddler you want? It would have to be
an nth parent sort of thing and I am not certain that would be any simpler
to use than what we have now.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ff6727c6-1409-464a-9519-25bdc9239895%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
BJ
2018-04-23 08:18:19 UTC
Permalink
The idea is that pop gets back to the previous value and can be nested:


<$vars currentTiddler=1>
<$vars currentTiddler=2>
<$vars currentTiddler=3>
currentTiddler is <<currentTiddler>><br>

<$pop><$pop>
currentTiddler is <<currentTiddler>><br>
</$pop></$pop>

</$vars>
</$vars>
</$vars>

*outputs:*


currentTiddler is 3
currentTiddler is 1

The advantage here is that there is no change to any tw syntax, so no
backwards compatibility issues.

BJ
Post by TonyM
Jed,
It is true that accessing the nth tiddlers info your be tricky, but just
being able to access the 0th would be enough to make big changes. By this I
am referring to the tiddler in the face of the user. The logical place they
are at, the item listed in the story. This makes me think perhaps we can
come at it from another approach.
Personally, It is not if it is core or not, just that a strait forward
system exists to reference all fields in the 0th, N-1 and N
If I understand BJ's suggestion its like the push and pop idea where the
list pushes items onto a list and pop steps back one item on the list.
Using stack metaphors.
As far as I can see although this may very well be helpful, the key
references will usually be the 0th, the Nth and the N-1th if you wish to
start referencing this such as N-2th or 5th etc... in another iteration, to
make the code understandable, then it is more reasonable to start using
additional variables etc...
Taking BJ's idea to push and pop his example pops to one layer before and
that happens to be the 0th layer. This is a great example of the N-1th,
note all we *need* is a way to reference the 0th without popping (imagine
we are 3-4 deep)
So on further consideration what if; as Jed said we had a "convenient
shorthand"
An enhancement to the <$list widget perhaps using a parameter, would allow
us to request a push (of the references) of the containing tiddler to a
stack, and then where ever you are in the nested lists you can either
reference 0th or N-1th field values and/or use pop (one or more or N
times). In reality a push need only be the storage of containing
tiddler-title, if subsequently we have a way of referencing the fields and
values from anywhere of that tiddlername. Basically the :N is replaced with
the appropriate tiddler title.
As an example (not literal) {{:-1!!fieldname}} {{:-N!!fieldname}}
{{:0!!fieldname:0}} including [[:N!!fieldname]] [[pretty|:N!!fieldname]]
[[pretty|:0!!fieldname]] especially [[pretty|:0!!title]]
Of course we could perhaps call these "relative tiddler names".
Alternatively we store the tiddlersname by name eg <$list push="parent"
make the tiddlertitle calling this list be stored as parent. Then you can
reference {{:parent!!fieldname}}
Perhaps some of Mario's uni-link tech could effectively provide dynamic
relative aliases.
Regards
Tony
Post by Jed Carty
It may be possible to add something like this to the core, but it
wouldn't be straight forward. The biggest problem is determining where the
outer containing tiddler is, like if you have multiple lists inside each
other how do you determine which containing tiddler you want? It would have
to be an nth parent sort of thing and I am not certain that would be any
simpler to use than what we have now.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/abe81fc8-e766-402f-931d-4c192f4e7356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2018-04-23 07:59:02 UTC
Permalink
I believe that we are counting in opposite directions. In the way I was
counting the 0th parent would be the current tiddler.

The biggest problem I can see with what you are suggesting where the 0th
parent is the outermost tiddler is that the numbering changes when you
transclude a tiddler. If you don't have your indexing based on the layer
where the calling happens than I think it would be very delicate because
you couldn't display the tiddler anywhere else without changing the
numbering.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/0c931e15-a940-401b-b718-e0706fe74121%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2018-04-23 08:29:12 UTC
Permalink
BJ,

That looks really good. I think that is the way to go.

TonyM,

Using the pop widget you could make macros like this:

\define parent1(field) <$pop>{{!!$field$}}</$pop>

\define parent2(field) <$pop><$pop>{{!!$field$}}</$pop></$pop>

and so on to go up through the ancestor tiddlers similarly to how you are
suggesting.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9fe5ecd8-b899-44cd-963e-fac2baf32d50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2018-04-23 10:54:38 UTC
Permalink
Post by TonyM
*My Special use case of a variable I do not use for logical (display or
dont display contents)*
A Common filter seems to be "[is[current]<fieldname>] -[[no]]" to display
if fieldname has a value of "yes"
IMO the right way to decide if you want to show something using the list
widget is

Using tag=script

<$list filter="[all[current]tag[script]]">
... your content comes here
</$list>




if a tiddler has the non empty field named: hugo

<$list filter="[all[current]has[hugo]]">
show me
</$list>



if a tiddler contains a field hugo, that contains the value "a"

<$list filter="[all[current]hugo[a]]">
show me
</$list>
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/323c0df4-8df7-461f-b29c-0676d016e3e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-04-23 13:55:28 UTC
Permalink
Mario,

Thanks, that is a lot cleaner but am I the only one who finds "all current" a bit non intuitive ?

Thanks
Tony
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/58b624d7-b3db-4e06-a185-5f7b4271812a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...