Yes, Mat. That's the question :)

On Monday, March 1, 2021 at 1:24:18 PM UTC+1 Mat wrote:

> @psigu...
>
> TL:DR; <https://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read> 
> Is this your question:
>
> >How can one loop through tiddlers which are two levels downstream in the 
> tag-hierarchy or further?
>
> If that is your question, I will attempt to reply. If you have some other 
> *complex 
> *question, I suggest you split it up into distinct questions, perhaps 
> separate posts, so that they can more easily be dealt with.
>
> <:-)
>
> On Monday, March 1, 2021 at 9:20:46 AM UTC+1 psigu...@gmail.com wrote:
>
>> Thanks, Soren, for the explanation and suggestions. My understanding of 
>> how the filters work is unfortunately very limited. I have been doing a lot 
>> of trial and error, sometimes finding a solution eventually, but too often 
>> without understanding of why it worked. Instead of continuing with that 
>> approach, I think asking a question and getting specific answers will lead 
>> to an increased understanding and it is already starting to pay off :)
>>
>> The looping operation I described in the last post is a macro triggered 
>> by a Select widget. I use the actions attribute of the Select widget to 
>> call this code as a macro. Closing the first list widget (for the first 
>> level) before running the same operation at the next level was actually the 
>> first thing I attempted but I didn't manage to get it to work. The second 
>> list widget in the following code does not work.
>>
>> <$set name="taskVisibilityValue" value={{!!task_visibility}}>
>> <$list filter="[all[current]tag[task]tagging[]]">
>> <$action-setfield $field="task_visibility" $value=<<taskVisibilityValue>> 
>> >
>> </$list>
>> <$list filter="[all[current]tag[task]tagging[]tagging[]]">
>> <$action-setfield $field="task_visibility" $value=<<taskVisibilityValue>> 
>> >
>> </$list>
>> </$set>
>>
>> What am I doing wrong?
>>
>> Note: The kin filter actually looks interesting and I might try it out if 
>> I will not solve it with core filter functionality or if I find more use 
>> cases for it.
>>
>> Best regards,
>> Pall
>>
>> On Monday, March 1, 2021 at 12:29:25 AM UTC+1 Soren Bjornstad wrote:
>>
>>> Your first $list widget is resetting the current tiddler, so in your 
>>> second $list widget the all[current] doesn't mean the same thing as it did 
>>> in the first. If I'm understanding your tiddler layout correctly, I think 
>>> you should be closing the first $list widget prior to starting the second 
>>> one.
>>>
>>> As for a better way, the kin filter 
>>> <https://bimlas.gitlab.io/tw5-kin-filter/> can be used to merge all the 
>>> levels of a multi-level hierarchy into a single list, which would prevent 
>>> you from having to try to make this recursive to handle an arbitrary number 
>>> of levels. I think you should be able to get that to work here.
>>>
>>> (Also, pretty sure you need a $button widget somewhere if you want to 
>>> trigger anything, unless I'm missing something – but maybe you just left 
>>> that out for brevity.)
>>>
>>> On Sunday, February 28, 2021 at 3:45:26 PM UTC-6 psigu...@gmail.com 
>>> wrote:
>>>
>>>> Oops, I missed the closing </$set> in both code fragments but that is 
>>>> not the issue.
>>>>
>>>> On Sunday, February 28, 2021 at 10:27:45 PM UTC+1 Pall Sigurdsson wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> This is my first post here. I discovered TiddlyWiki last November and 
>>>>> got hooked by its power and beauty. I challenging myself into programming 
>>>>> something which was supposed to be very simple in the beginning but who 
>>>>> knew that this would become so addictive? Anyhow, I have a question I'm 
>>>>> hoping someone here could help me with.
>>>>>
>>>>> How can one loop through tiddlers which are two levels downstream in 
>>>>> the tag-hierarchy or further? I already figure out how to copy a field 
>>>>> value from the current tiddler to all tiddlers which are tagging it and 
>>>>> which also have the tag 'task' but what I think I need help with is to 
>>>>> propagate the value 2-3 levels further.
>>>>>
>>>>> The following code fragment reads the task_visibility (custom) field 
>>>>> of the current tiddler and applies it to the next level below (only to 
>>>>> tiddlers which are also tagged with 'task').
>>>>>
>>>>> <$set name="taskVisibilityValue" value={{!!task_visibility}}>
>>>>> <$list filter="[tag[task]tag<currentTiddler>]">
>>>>> <$action-setfield $field="task_visibility" 
>>>>> $value=<<taskVisibilityValue>> >
>>>>> </$list>
>>>>>
>>>>> Note: The filter above can be replaced with 
>>>>> "[all[current]tagging[]tag[task]]" - it works just the same.
>>>>>
>>>>> One of the things I tried for taking this one level further down the 
>>>>> task hierarchy was nesting the lists:
>>>>>
>>>>> <$set name="taskVisibilityValue" value={{!!task_visibility}}>
>>>>> <$list filter="[all[current]tagging[]tag[task]]">
>>>>> <$action-setfield $field="task_visibility" 
>>>>> $value=<<taskVisibilityValue>> >
>>>>> <$list filter="[all[current]tagging[]tagging[]tag[task]]">
>>>>> <$action-setfield $field="task_visibility" 
>>>>> $value=<<taskVisibilityValue>> >
>>>>> </$list>
>>>>> </$list>
>>>>>
>>>>> This code still works only on the first level below the current 
>>>>> tiddler. Does anyone know how to apply this to the next level below the 
>>>>> first child level (and further)?
>>>>>
>>>>> I'm also wondering whether it is a good idea to do this (or how far 
>>>>> down to go), whether there are performance issues to be expected with a 
>>>>> loop like this, when the hierarchy below the current tiddler might 
>>>>> contain 
>>>>> dozens of tiddlers.
>>>>>
>>>>> Best regards,
>>>>> Pall
>>>>> - Currently on version 5.1.23
>>>>
>>>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/46add0a8-5a99-4b49-8b23-14d4555a07cdn%40googlegroups.com.

Reply via email to