Does it mean I have to overwrite the core tiddler?
becuase I assume TW process its own Viewtemplates and then user ViewTemplate! So, it will show the body when it process its own Viewtemplates!
Nothing in your demo seems to be working right now.
You can use CSS to hide everything. Then in your viewtemplate either reveal your sections or reveal the original tiddler contents. But maybe I am not understanding the question.
So use CSS to make ALL tiddlers hidden. Wrap your own transclusions with a different class and use another CSS so the higher specificity will make them appear when you want. Yeah, I’m just guessing that it might work
@Mohammad when creating tiddlers from a template you have the advantage of being able to set hide-body=yes at create time, but I understand the gap you want to fill.
See below for a solution:
First keep in mind the following;
A number of solutions return to modifying $:/core/ui/ViewTemplate/body so it is worth doing down this path however remember you can clone this to your own edited version and remove from the core version by removing the tag $:/tags/ViewTemplate or even better change the tiddler set in $:/config/ui/ViewTemplate after cloning your own version of $:/core/ui/ViewTemplate . Thus the core tiddlers will update but your toggle remains available, and active.
The thing is hide body is triggered only by !field:hide-body[yes] in $:/core/ui/ViewTemplate/body you could change this as follows;
From <$list filter="[all[current]!has[plugin-type]!field:hide-body[yes]]">
to <$list filter="[all[current]!has[plugin-type]!field:hide-body[yes]!subfilter<hide-body-condition>]">
Where hide-body-condition is a filter set by you in a global macro that also stops the display of the body if true.
I have long felt this was a missing hack we could provide in the standard distribution!
Although it could be opened up more to also provide other useful hacks.
It shows how you use the data-tiddler-title to target tiddler names however it can be wrapped in a list filter, you choose. Any filter will be do but according to your original request.
I am confident this issue highlights a need for either overriding core tiddlers or adding some new hackability to the core.
First if Mohammads solution is only used for a few tiddlers the generation of a tiddler list inside a stylesheet, it should be fine but as mario points out it is not scalable.
With the simplification of edit on the current tiddler, new form handling and views are possible, the need to efficently handle programaticaly the hiding of the body to use another “view” will become essential. Current workarounds are clumsy, require interaction or inefficent or not scalable.
As @pmario said, using a stylesheet with a conditional $list creates huge css tiddler over the time!
I think a possibility to hide body of tiddlers with simpler solution should be provided into the core!
The use case here is the Section Editor!
You only need to change your field name: se-body to hide-body: yes and you are done, without changing anything.
If users are not able to write the field provide a button, that sets it.
If the field `hide-body isn’t enough info to activate your editor tag the tiddler “se-editor” and add an extra template tiddler that shows your editor.
If the existing mechanism isn’t good enough overwrite the shadow tiddler. It contains 7 lines of code. So if it will be changed in the core, there should be an easy fix. …
Sorry if it sounds harsh: IMO all the components are there you are just not willing to use them.