Convert tag pills to links when creating static html?

97 views
Skip to first unread message

David Gifford

unread,
Nov 12, 2016, 11:45:10 AM11/12/16
to TiddlyWiki
Hi guys

I don't know if this is possible, but I was wondering if there would be a way to convert tag pills to links to the tiddlers for those tags when exporting all tiddlers as static htmls.

Having this feature would facilitate navigation between statics of each tiddler if one also created a tiddler for each tag with a list of tiddlers tagged with that tag.

So, say I have static htmls from a TW, and the Abraham Lincoln tiddler is tagged US presidents. Current behavior when clicking on that tag pills is...nothing. Static means no popups or anything. But if clicking on the tag pill took me to the static html US presidents, and that tiddler had a list of all tiddlers tagged US presidents, then I could from there navigate to Barack Obama or George Washington.

Is there any way to tweak my TiddlyWiki to create this behavior?

Dave

Mark S.

unread,
Nov 12, 2016, 1:06:56 PM11/12/16
to TiddlyWiki
I'm sure someone will come up with a more elegant solution, but if you replace the contents of:

$:/core/ui/TagTemplate

with

<$link><$view field="title" format="text" /></$link>

Then all your tag buttons will become links (of course, this assumes they have something to link to). Then do your export -- it worked for me on a quick test with the table of contents from tiddlywiki.com. Afterwards, delete $:/core/ui/TagTemplate to restore it to its original shadow status.

Good luck,
Mark

David Gifford

unread,
Nov 12, 2016, 10:55:23 PM11/12/16
to tiddl...@googlegroups.com
Thanks Mark!

Bonus to you anyone who can make the links still look like tag pills, and pull from the color field of the tag's tiddler for the color of the tag pill.

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/d6-mFX9fchs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/70c9a3df-ee24-4c0b-8005-5bd7ce4d4e78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Gifford
Christian Reformed World Missions, Mexico City

David Gifford

unread,
Nov 12, 2016, 11:10:33 PM11/12/16
to TiddlyWiki
This gives me tag pills as links

<$link><span class="tc-btn-invisible tc-tag-label"><$view field="title"/></span></$link>

but doesn't adjust the background color based on the color field of the tiddler.

David Gifford

unread,
Nov 12, 2016, 11:32:18 PM11/12/16
to TiddlyWiki
Hey Mark

This tweak did the trick. Thanks for nudging me to the right tiddler to tweak, and for giving me just enough to be able to figure it out!

Dave

\define tag-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end

\define tag-body-inner(colour,fallbackTarget,colourA,colourB)
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<$link><$button class="tc-btn-invisible tc-tag-label" style=<<tag-styles>>>
<$transclude tiddler={{!!icon}}/> <$view field="title" format="text" />
</$button></$link>
\end

\define tag-body(colour,palette)
<span class="tc-tag-list-item">
<$macrocall $name="tag-body-inner" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}}/>
</span>
\end

<$macrocall $name="tag-body" colour={{!!color}} palette={{$:/palette}}/>
Reply all
Reply to author
Forward
0 new messages