Is there a way to have an entry in the table of contents configurable at run time? For example, I may have a wiki that has a toc entry called ‘development’ that I only want visible in certain situations and hidden when in public use. So the table of contents tag
Depending on your usecase, yes!
If you are just looking to hide it but still keep it in the wiki itself, this can be done using a stylesheet, similar to how edit controls are hidden using the read only theme.
However, if it is sensitive data you do not want to risk others viewing, your best bet is to export these tiddlers, or you can use the encrypt individual tiddlers plugin in conjunction with the stylesheet that hides tiddlers based on tags, to keep it in the wiki but inaccessible.
I actually deal with a fair bit of PPI and sensitive info that I don’t want shared with collegues who i share my notes with, so I encrypt and export them.
Tbh, I’d love a way to view those tiddlers wothout importing them, which is possible, but I havent yet figured out how. I believe it involved the uri field. Anyways, getting off track here.
I am currently on mobile so I don’t have an exact code snippet of how the stylesheet should look, but I will update my comment with something once Im back to my laptop
Edit: give this a go
Title:"$:/bob-jansen/styles/hide-development"
Tags:"$:/tags/Stylesheet"
Text:"
[data-tiddler-tag="Development"] {
Display: none;
}"
Edit: ah, I see I misunderstood the question whoops. Well I will leave the above just in case it helps someone else, but I believe ericShulmans response is a better fit.
You can use the exclude
parameter of the toc macro to omit the “development” tag from the TOC tree display.
So, for example, if you add exclude:"development"
to the toc macro in your Table of Contents tiddler, the TOC will never show the “development” tag (as well as any tiddlers that use only that tag).
To make this conditional:
- First, you will need to use the
$macrocall
or$transclude
method of invoking the toc macro. This will allow you to use a computed value for theexclude
parameter. - Next, let’s suppose your “certain situations” is determined by, for example, local vs. hosted viewing. To detect this condition, you can check the value of
$:/info/url/protocol
to see if it matches (or doesn’t match) “file:” - Then, you can define the TOC
exclude
parameter like this:
exclude={{{ [{$:/info/url/protocol}!match[file:]then[development]] }}}
Let me know how it goes.
enjoy,
-e