Hide Tiddler Body

@Mark_S - This question is related to Section Editor (SE), where we have to parse the text field by SE and hide what the Core template displays!

It is possible to hide tiddler body using css or hide-body field! I think Streams by @saqimtiaz uses a button to add this field manually!

We can use such a button for all tiddler and when the field is added hide the button!

Still I am looking for simpler solution!

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.

I will update the demo on GitHub by tonight!

You got the question.

In the current demo I use a tiddler with below styles to hide tiddler body

tag: $:/tags/Stylesheet
text:

\define assign-css()
\rules only
[data-tiddler-title="$(currentTiddler)$"] .tc-tiddler-body { display:none; }
\end
<$list filter="[all[tiddlers]has:field[se-type]]">
<<assign-css>><br>
</$list>

But it will add a lot of tiddlers! I think there is no attribute for field like tags or title e.g. for title we have

data-tiddler-title=

but for field I have not seen anything like below

data-tiddler-field="se-type"
1 Like

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 :sweat_smile:

@Mohammad must it really be in a viewtemplate?

Otherwise, this should give you the general idea:

tags: $:/tags/Stylesheet
text:
\define foo() [data-tiddler-title="$(currentTiddler)$"] .tc-tiddler-body { display:none; }
<$list filter="..."><<foo>></$list>

@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.

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.

2 Likes

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

1 Like

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.

1 Like

@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.

1 Like

My reply was about this post: Hide Tiddler Body - #19 by Mohammad

My take was that Mohammad wanted this to happen automagically, without requiring the user to press a button. Otherwise I’m mystified too :smiley:

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.