Icons in tree macro

68 views
Skip to first unread message

david.j....@gmail.com

unread,
Dec 16, 2020, 3:01:30 PM12/16/20
to TiddlyWiki
Is there a simple way to associate an image/icon with a tiddler (such as an icon field), so that the icon will show up in the tree macro?

Something like tiddlers
H:/Location/Location 1
H:/Location/Location 2

With the following tree:
<<tree "H:/Location/">>


With each Location 1 and Location 2 being able to have a unique icon image in the tree instead of the default icon.

Thanks,
David

TW Tones

unread,
Dec 16, 2020, 6:43:16 PM12/16/20
to TiddlyWiki
David,

The tree macro is defined here $:/core/macros/tree
  • you could modify it to get the desired result
  • or make a new one of your own
  • Consider if it has an icon use it if not use the default.
  • Perhaps its best to also display the icon if its exist and still display the defaults because it indicates file or "folder".
  • Inside the macro that defines the link displayed the variable <<full-title>> is the actual tiddlername 
The following is a modification of one of these macros to display an icon on leaf items if it exists;
\define leaf-link(full-title,chunk,separator: "/")
<$set name=icon-tiddler tiddler=<<__full-title__>> field=icon>
<$link to=<<__full-title__>>> <$transclude tiddler=<<icon-tiddler>>/> <$text text=<<__chunk__>>/></$link>
</$set>
\end

Regards
Tones
Reply all
Reply to author
Forward
0 new messages