How to Hide titles in a list, that also have a draft tiddler

The following solution is the most elegant way to improve the handling of drafts in custom lists;

See the below solution by Eric, the best solution is to use -[get[draft.of]] to remove original titles also with a draft tiddler.

<$list filter="[tag[$:/tags/SideBar]] -[get[draft.of]]">

</$list>

Background

For example;

<$list filter="[tag[$:/tags/SideBar]]">

</$list>

Will list all tiddlers tagged $:/tags/SideBar

  • This includes the original title AND the draft title if one of the above tiddlers is in draft mode;
<$list filter="[tag[$:/tags/SideBar]!has[draft.of]]">

</$list>

Example Result

$:/core/ui/SideBar/Open
TableOfContents
$:/PSaT/bookmarkletMaker/sideBar-list
$:/PSaT/edit-recent/sidebar
$:/PSaT/edit-recent/sidebar-system
$:/PSaT/history-sidebar
Draft of '$:/PSaT/history-sidebar'
  • See the last two items they are the same tiddler one in draft.

We can exclude tiddlers with draft using !has[draft.of]as below.

<$list filter="[tag[$:/tags/SideBar]!has[draft.of]]">

</$list>
  • This will exclude draft tiddlers and only list the original title

So is there a simple way that displays the draft tiddler BUT NOT the original tiddler in such lists?

  • That is will exclude original title when a matching draft title is in the list.
  • Remember there is a possibility of a draft tiddler existing but not in the story

Another way to ask the same question is;
For a given <<currentTiddler>> how do we test to see if it has a “draft tiddler” existing, so we can exclude <<currentTiddler>> from the filter result.

Thanks in advance, once I have an answer I will turn this into a How to Instruction!

1 Like

How does this work for you:

<$list filter="[tag[ActionWidgets]has[draft.of]removeprefix[Draft of ']removesuffix[']]" variable=beingEdited>
<$list filter="[tag[ActionWidgets]] -[<beingEdited>]">

</$list>
</$list>

I have found an answer but it compares each title against a list of all draft tiddlers;

\define has-draft() [all[tiddlers]get[draft.of]]
<$list filter="[tag[$:/tags/SideBar]] -[subfilter<has-draft>]">
   <$link/> <br>
</$list>
  • So with has-draft defined we remove from our list any title that “has-draft”
  • There is a reasonable assumption that any tiddler in draft is a “tiddler”,
    • Because shadow tiddlers are no longer shadows when in draft
    • System tiddlers are also “tiddlers”
  • has-draft can be a local or global macro

Original titles with draft
{{{ [subfilter<has-draft>] }}}

The value of the draft.of field contains the title of the tiddler being edited. Thus, you can use this value to exclude the “original title” from the filter result, like this:

<$list filter="[tag[$:/tags/SideBar]] -[get[draft.of]]">

</$list>

-e

1 Like

@EricShulman that is very elegant

In your example you rely on the default list item template; and uses the caption if available,

  • whilst my example can as well;
\define has-draft() [all[tiddlers]get[draft.of]]
<$list filter="[tag[$:/tags/SideBar]] -[subfilter<has-draft>]">

</$list>

My example is unnecessarily complex and needs the macro.

I have found a case where none of these methods work. If I learn anything I will share back, its not an easy example to share.