[tw5] three queries. problems adding a checkbox to TOC, how to create a template for checklists that works with any tiddler and creating a checklist that opts for the title when no caption exisits

405 views
Skip to first unread message

Raymond McDowell

unread,
May 19, 2015, 8:53:11 PM5/19/15
to tiddl...@googlegroups.com
Sorry if this is too many queries at the same time.

Here is my situation. I use my TiddlyWiki as a PKM. This includes my writing projects, catalogs, all my projects and tasks, reference materials and journals.

Query 1) How to add checkboxes to a TOC.   To keep a status update, I use checkboxes to note where I am in my overall process. Jed generously offered a suggestionI previously how I could add a checkboxes to my TOC
 (see https://groups.google.com/forum/#!searchin/TiddlyWiki/TOC$20checklist/tiddlywiki/Mc0kwDIkanQ/es1Uexk4-9QJ). However I found that the checkbox disappeared as soon as I compressed the TOC entries or refreshed my wiki. Could anyone advise what I'm doing wrong here?

Query 2) How  to create a template for checklists that works with any tiddler.  I often use the the existing task management function as noted on Jeremy's TaskManagementExample on the tiddlywiki.com site.  It would be nice if there were a template I could use to apply to a given tiddler, thereby creating a checklist that uses the current tiddler title as the tag being used.  (I hope that makes sense.)

Query 3) How to create a checklist that can display either the caption (if one exists) or the title (if there is no caption) on the checklist list.

Some of these may be obvious, or they may not be possible. In any case, I appreciate any suggestions.

Thanks,

Ray


Jed Carty

unread,
May 19, 2015, 9:37:40 PM5/19/15
to tiddl...@googlegroups.com
For the first one:

Looking at the code I gave you now I am a bit embarrassed. The checkbox state has no persistent storage, so anytime the toc is refreshed the state would be reset like you are seeing. This shouldn't have that problem. It may have other problems I haven't seen. Also it is only adding one line to the default toc macro:

\define my-toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$checkbox tiddler="""$(currentTiddler)$""" tag='done'/>
<$link>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
</$list>
<<toc-caption>>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
</$set>
\end

This will give the the tag 'done' when the box is checked. If you don't want to put the tag on the tiddler itself but still have a persistent state replace """$(currentTiddler)$""" with
<<toc-state>>
And you can of course change the checkbox to use a field or another tag.

I am not sure exactly what you are asking for the second one. Do you want a checklist that when each item is checked it gets tagged with the current tiddler?
If so you could make a macro like this (this also adds the answer to the third part):

\define makeChecklist(filter)
<$set name='taggingTiddler' value=<<currentTiddler>>>
<$list filter='$filter$'>
<$checkbox tiddler=<<currentTiddler>> tag=<<taggingTiddler>>><$view field='caption'><$view field='title'/></$view></$checkbox><br>
</$list>
</$set>
\end

Put this in a tiddler, tag that tiddler with $:/tags/Macro and then in any tiddler you put <<makeChecklist '[tag[something]]'>> (replace [tag[something]] with the filter you want to use to make the checklist) and it will create the list in that tiddler.
If you want to click on the caption/title and open the tiddler instead of toggling the checkbox than you would replace the checkbox widget with this:
<$checkbox tiddler=<<currentTiddler>> tag=<<taggingTiddler>>/><$link to=<<currentTiddler>>><$view field='caption'><$view field='title'/></$view></$link><br>

For the third one the answer is easy enough:

<$list filter=<<whateverfilteryouusetomakeyourlist>>>
<$checkbox tiddler='somestatetiddler' field=somefield checked=checkedvalue unchecked=uncheckedvalue><$view field=caption><$view field='title'/></$view></$checkbox>
</$list>

or you can have the checkbox linked to a tag or whatever. The <$view field='caption'><$view field='title'/></$view> is the important part. If what you tell a view widget to display exists than anything between <$view> and </$view> is ignored, but if what you tell it to display doesn't exist whatever is inside the tags is displayed instead.

Like I said, I am a bit embarrassed that I missed that problem before. Sorry about that.

Raymond McDowell

unread,
May 19, 2015, 10:51:51 PM5/19/15
to tiddl...@googlegroups.com
Thanks Jed. I'll work with that. For the second question, I mean that I would like a single template where I don't need to make any modifications that uses the current tiddler as the tag and makes a checkboxed list.  That way all I need to do in any given tiddler is just call that template and i magically have a checkboxed list of all tiddlers that are tagged with that tiddler.

Sorry if I'm not stating that as clearly as I should

ceri...@gmail.com

unread,
Feb 17, 2018, 8:05:08 PM2/17/18
to TiddlyWiki
Jed:

I came across this post while searching for a solution to my current situation.

I have a TW5 wiki that contains my book collection. I have tiddlers for each author, and tiddlers for each book by that author. I have used the toc macro: toc-selective-expandable to create my nested listing. What I am wanting to do is add a checkbox to each book in my list, so that when I have completed reading it I can check it off,
give it a status of "Read" and strike through the title.

Your code gave me a start but since I am not a programmer I do not understand how to get a checkbox next to each book title. This code only places a checkbox next to
the authors name.

Example of what I am trying to achieve:

> Douglas Preston & Lincoln Child
    [ ] The Relic
    [ ]  Riptide

> James Rollins
    [ ]  Ice Hunt
    [ ]  Excavation

What I have today:

[ ] > Douglas Preston & Lincoln Child
    The Relic
    Riptide

[ ] > James Rollins
    Ice Hunt
    Excavation

How would your code be modified to do what I want?

Thank you in advance for your time.

Charles

Mark S.

unread,
Feb 18, 2018, 9:46:43 PM2/18/18
to TiddlyWiki
Are you sure you got the different pieces of macros from the 2 threads together correctly?

When I try it, I get a checkbox both at the parent and the child level. I also get everything enumerated which might mean that I need a different CSS tiddler.  It looks to me like you would like Jed's code tweaked so that it no longer shows a checkbox at the parent level. I'm thinking this might require marking the parent tiddlers with a "Parent" tag (or maybe there is already an "Author" tag which would be the same thing)

-- Mark

Jed Carty

unread,
Feb 19, 2018, 3:17:33 AM2/19/18
to TiddlyWiki
The way that the TOC runs recursively means that it is a bit more complex to do what you are asking than it may seem.

I have made another list type that may help with what you want though:


I also made a library tracker but it doesn't have everything you want. http://inmysocks.tiddlyspot.com/#%24%3A%2Fplugins%2Finmysocks%2FLibraryTracker%2FLibrary%20Tracker

I am working on something more like what you are talking about that is a combination of the two but I don't think I have it online anywhere. I will post in the group when it is available.

ceri...@gmail.com

unread,
Feb 20, 2018, 4:50:18 PM2/20/18
to TiddlyWiki
Mark

In my attempt to create the hierarchical list of books by author I only concentrated on the my-toc-selective-expandable macro that Jed provided, since that seemed like it would produce the desired outcome. Initially I ignored the other part of his post on the other macros. In trying those I am able to produce, a linear checklist of all Authors and all Books not a checklist showing Parent (author)/child (book) with checkboxes next to each child.. My
programming skills are not very good. Perhaps you could show me what you did to produce your results.

Thank you for taking the time to look into my situation and responding.

Charles

ceri...@gmail.com

unread,
Feb 20, 2018, 4:52:19 PM2/20/18
to TiddlyWiki
Jed

Thanks for your reply. I will keep a look out for future posts.

Charles
Reply all
Reply to author
Forward
0 new messages