Si,

I opened this thread 
<https://groups.google.com/forum/?hl=en#!topic/tiddlywiki/RTzc2MGT__Y>to 
introduce the idea of building your own TOC macros when more detailed 
customisation I required.

I have looked at a sophisticated solution to similar requirements to your 
own, if I can I will add it to the above thread.

This would be my design approach

   - Use my own Recursive macros (not the TOC macros)
   - Permit the addition of a field in any tiddler eg tableofcontents-filter
   - Since the same tiddler could be a member of another toc I suggest this 
   filter field be named related to the root tiddler.
   - If the field exists with a value use this as the next level filter to 
   call "each-other-level"
   - The filters in tiddlers should decide which children to show in the 
   next level down. 
   - Remember the filter may be recursive (called over and over again) so a 
   filter in a tiddler should perhaps define only a limited set of tiddlers.

Regards
Tony

On Wednesday, January 22, 2020 at 5:50:32 AM UTC+11, si wrote:
>
> Hi Mark.
>
> Sorry I realize that I had made my post more convoluted than it needed to 
> be.
>
> *What I want to do is apply a filter to only a specific tiddler and its 
> descendants within a TOC. Any tiddlers higher up in the hierarchy should 
> not be subject to the filter.*
>
> By adapting your solution I am able to do this for a filter that 
> *excludes* certain tags, but not for a filter that returns *only* tiddlers 
> with a certain tag.
>
> Thank you for your patience. Si
>
> On Tuesday, January 21, 2020 at 4:10:20 PM UTC, Mark S. wrote:
>>
>> !!tag-filter will use the tag-filter field of the tiddler from which the 
>> TOC macro is launched.
>>
>> It's unclear where you want the tag-filter field to be coming from.
>>
>> It seems like you want a tiddler to have a tag-filter field AND be marked 
>> "spam", which doesn't quite make sense to me.
>>
>> Sometimes it helps to explain the big picture of what you want to do, 
>> rather than look narrowly at a particular technological solution.
>>
>> Good luck!
>>
>> On Tuesday, January 21, 2020 at 7:49:17 AM UTC-8, si wrote:
>>>
>>> Thank you Mark, that works perfectly, but I have realized that it is 
>>> less adaptable than I initially thought.
>>>
>>> I have tried adapting it to filter for *only* tiddlers tagged with 
>>> "spam".
>>>
>>> I first tried the following with the field "tag-filter=spam" in the 
>>> section I want to filter:
>>>
>>> <<toc-selective-expandable 'Section' 
>>> sort:"sort[title]]+[tag{!!tag-filter}">>
>>>
>>> The problem is that in other sections without a "tag-filter" field the 
>>> filter becomes "[sort[title]]+[tag[]]" which returns nothing.
>>>
>>> I've spent the last hour trying to figure out another way of doing it to 
>>> no avail. Can you see a way to do this?
>>>
>>> Thanks again for your help.
>>> On Monday, January 20, 2020 at 6:33:46 PM UTC, Mark S. wrote:
>>>>
>>>> You can use the sort attribute to insert whole filter runs. However, 
>>>> the syntax will look lopsided:
>>>>
>>>> <<toc-selective-expandable 'Section' sort:"sort[title]]+[!tag[spam]">>
>>>>
>>>> Notice that the brackets are not balanced. Basically the macro is 
>>>> providing the final, right-hand square bracket. You need to provide sort 
>>>> criteria because you're over-riding the default.
>>>>
>>>> This seemed to work in my tests. Topmost elements were tagged with 
>>>> "Section" so that they all hung together.
>>>>
>>>> Good luck!
>>>>
>>>> On Monday, January 20, 2020 at 6:08:24 AM UTC-8, si wrote:
>>>>>
>>>>> Hi folks.
>>>>>
>>>>> How could you exclude all tiddlers with a certain tag from a 
>>>>> Table-of-Contents, but *only* within a specific sub-section of the 
>>>>> hierarchy?
>>>>>
>>>>> For example, say that I have a the following table of contents:
>>>>>
>>>>>    - Section1
>>>>>       - Subitem
>>>>>       - Subitem
>>>>>    - Section2
>>>>>       - Subitem
>>>>>       - Subitem
>>>>>    - Section3
>>>>>       - Subitem
>>>>>       - Subitem
>>>>>    
>>>>> How could I apply a filter to the macro that excludes all tiddlers 
>>>>> with the tag "spam", but only apply it to the descendants of "Section2"?
>>>>>
>>>>> I have tried a couple of things so far:
>>>>>
>>>>> First I tried creating separate Table-of-Contents macros for each 
>>>>> Section:
>>>>>
>>>>> <div class="tc-table-of-contents">
>>>>>
>>>>> <<toc-selective-expandable 'Section1Tag'>>
>>>>> <<toc-selective-expandable 'Section2Tag' sort:"!tag[spam]">>
>>>>> <<toc-selective-expandable 'Section3Tag'>>
>>>>>
>>>>> </div>
>>>>>
>>>>> This works but puts a blank line between each section in the TOC. 
>>>>> Maybe I'm being nitpicky but it makes the TOC look much uglier than it 
>>>>> needs to and takes up an impractical amount of space when you have a lot 
>>>>> of 
>>>>> sections.
>>>>>
>>>>> I have also tried using the following:
>>>>>
>>>>> <div class="tc-table-of-contents">
>>>>>
>>>>> <<toc-selective-expandable 'TableOfContents' sort:
>>>>> "!tag{!!exclude-tag}">>
>>>>>
>>>>> </div>
>>>>>
>>>>> And then adding the field "exclude-tag=spam" to the "Section2" 
>>>>> tiddler. This didn't work at all.
>>>>>
>>>>> Does anyone know of a tidy way to do this?
>>>>>
>>>>> Thanks a lot for your help. Si
>>>>>
>>>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7de41251-e64b-4f7e-b8bf-4a9760a16e1e%40googlegroups.com.

Reply via email to