Hi Mat, yes, this is what I use now! the only minor issue is for a lot of tiddlers we have a very big stylesheet, but it works!
Thanks Tones! as this will be used in a plugin, I am hesitant to touch core tiddlers! otherwise your solution works!
Could you use the class field rather than the hide-body to introduce css to display none?
Not sure how but it would seem possible.
If we could have something like below
Mohammad,
See here ## Q: How can I use a custom field to style a tiddler?
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.
[all[]has:field[job]]
<$list filter="[all[]has:field[job]]">
[data-tiddler-title^="<$view field=title/>"] .tc-tiddler-body {
display: none;
}
</$list>
Should do it! Maybe a lot of tiddlers but you do not need to list them.
No should not do it that way. First of all it will create a huge CSS that will need to be recalculated way to often.
Second the body DIVs are created in the DOM which need time, just to be hidden with CSS.
It’s a very efficient way to waste performance. … If that’s the goal.
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.
We need a solution
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!
The core already provides a mechanism to change the ViewTemplate in exactly the way you describe it.
see: https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FViewTemplate%2Fbody
<$list filter="[all[current]!has[plugin-type]!field:hide-body[yes]]">
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.
Just my thoughts.
Thank you Mario! In original OP, I said I am fully aware of these possibilities and you can see these solutions with examples in TW-Script where I have documented them months ago!
I think I have found some possible solutions advised by @saqimtiaz and I will share my final solution once it worked for me!
Thank you any way!
Mario i agree with your sentiment but that filter could be externalised to a config tiddler as well.
Perhaps even a smart filter that uses the external filter if it exists otherwise the default.
Actually I think we could address some other non hackability issues in the viewtemplate in the same change. I would like to see some conditional import macros and styles that wrap the body before render.
In part extending the current edit and view templates to allow additional modes efficiently.
@TW_Tones Look t this: Hide Tiddler Body Programmtically · Discussion #6089 · Jermolene/TiddlyWiki5 · GitHub and especially this: [IDEA] Prevent double rendering when $:/core/ui/PageTemplate is open in the story · Issue #5136 · Jermolene/TiddlyWiki5 · GitHub post at github.
My take was that Mohammad wanted this to happen automagically, without requiring the user to press a button. Otherwise I’m mystified too
I think Mat was talking about “hooks” in code. If there was a “hook” when you closed a tiddler, then things like the hide-body field could be added at the time a tiddler was saved.
There are some hooks, but they are JS only. … BUT there is a discussion going on at GitHub to change that.
The idea is to expose all of the functions that the navigator-widget handles atm, will be “extracted” and should be available with several action-like widgets.
also see: Implement more of TiddlyWiki's black box logic as customisable action strings · Issue #3967 · Jermolene/TiddlyWiki5 · GitHub At the end of the issue, there are a lot of other issues that reference this one. … So there is quite some potential
On a related issue tiddler folding and desired support from navigation
I will just remind us all we already have the fold tiddler button and bar. This is toggled by the existence of a tiddler. This can be automated but requires a trigger. Most people when adding something to the view templates do not include the code to hide the output when the fold tiddler button is used.
This means the fold facility only closes the core output like rendering the body (Tags and Subtitle) which has a similar effect as the hide-body field being set to yes, but can be reversed with the button on the view tool bar, or the foldbar is used to unfold.
It seems to me there is a systematic gap here that if addressed would be easy to solve. Exposing the functions of the navigator widget may help.
@pmario perhaps you could ensure the GitHub discussion considers this but the navigation process is a potential trigger that occurs once each time a tiddler is opened and an appropriate place to test a condition and initiate an action.
A standard work around because its hard to trigger an action in the viewtemplate
If we go back to @Mohammad 's Original question the best work around is to set the hide-text field or fold status toggle at the moment you create or nominate a tiddler for this purpose. I am building a solution not unlike the “edit-section” solution and have simply made the fold button appear;
<$list filter="[all[current]has:field[job]]">
{{||$:/core/ui/Buttons/fold}}
....
how to hide tiddler body?
</$list>
This only demands a one off manual intervention.
Personally I have felt one way we protect users is to not allow us to set an action on open tiddler, one could make an action to close the tiddler on open, or open all tiddlers on open - for example. This could get messy.
However it is stopping us developing a whole class of solutions.
I have worked in building “Standard Operating Environments” (desktop/OS) and application and software distribution in large corporate environments. Both windows itself and the install/ distribution tools typically include a “run once” functionality. Once run It will not run again and this protects it from re-occurring or looping.
Perhaps we can provide a conditional run once on opening a tiddler that can be set in the view template but which the navigation or open tiddler trigger can result in an action. This could conditionally set or fold the tiddler on first navigation, or manual creation.
IMO this would only be a workaround for a very specific usecase. The one described in the OP. …
What we need is a generic solution, similar to the one discussed at github.
As I wrote in the tread there, it would be worth to explore the possibilities. … It may be possible to remove the boundaries between view-mode and edit-mode, which may open up a lot of new possibilities.
Hiding / showing different elements would be 1 of them.
Actually I am asking for the facility to conditionally trigger actions on open tiddler a general facility. There examples may include;
- Render a large tiddler and take a snapshot, display that snapshot only so that the large tiddler is not re-rendered until requested.
In my view this would be a generic solution, but if it can be satisfied by the other one all the better.
See my comments in the same thread.
Folks - see my recent solution The quickest and easiest ever todolist in tiddlywiki ? Requires 5.2.0 - #2 by TW_Tones for an example of why we could use a way to programaticaly hide the body, in this example I provide a fold button as the work around.
Also @Mohammad see inside quicklist for a method I employed to simply parse the lines similar to Section Editor - Prototype it may prove of use in the future.
Section-Editor respects the core tiddler folding state using the below viewtemplate
<$list filter="[all[current]has:field[se-type]!field:hide-body[yes]]">
<$reveal tag="div" class="xtc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes">
<$list filter="[all[current]!has[plugin-type]!field:hide-body[yes]]" variable=NULL>
<$vars hn={{{ [[$:/plugins/kookma/section/configs-hn]get[text]else[2]] }}} > <!-- default number of headings 2 -->
<$macrocall $name=section-editor source=<<currentTiddler>> pattern=<<pattern>> />
</$vars>
</$list>
</$reveal>