Hide Tiddler Body

There are a number of solutions to hide tiddler body like using CSS or hide-body field!

My question is how can I do this conditionally in a view template? For example consider below view template:

title: …
tag: $:/tags/ViewTemplate
text:

<$list filter="[all[current]has:field[job]]">
....
how to hide tiddler body?
</$list>

There is a mechanism to “fold and unfold” tiddlers. You can use this one. It does what you describe.

See ControlPanel : Appearence : Toolbars : ViewToolbar …

OR

See: https://tiddlywiki.com/#TiddlerFields - search for hide-body field

Open: https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FViewTemplate%2Fbody in edit mode to see, how it works

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!

Am I wrong?

Maybe you could hide ALL the bodies. Then use your viewtemplate to insert what your want, and restore the body if it doesn’t match what you want.

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