Hide Tiddler Body

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.

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>
1 Like

@Mohammad I was looking at how you are hiding the core/ViewTemplate/Body and display the sections viewtemplate. I want to similarly display a table with editor in one column and preview in the other column like shown below.

This table is in a tiddler called Alternate editor

I created a config tiddler called $:/config/ViewTemplateBodyFilters/Alternate editor with tag $:/tags/ViewTemplateBodyFilter and its content as

[has:field[ae-type]!field:hide-body[yes]then[$:/plugins/arsheth/editor/viewtemplates/alternate editor]]

Now I created a tiddler called $:/plugins/arsheth/editor/viewtemplates/alternate editor
How should I modify your code in the the tiddler $:/plugins/kookma/section/viewtemplates/sections so that my table in the tiddler Alternate editor is shown in tiddler with field ae-type instead of the tiddler body.

\import $:/plugins/kookma/section/macros/main
\define filterpattern() ^\[.*\]$

<$list filter="[all[current]has:field[se-type]]"> 
<$reveal tag="div" class="se-tc-tiddler-body" type="nomatch" stateTitle=<<folded-state>> text="hide" retain="yes" animate="yes">
<$list filter="[all[current]] :filter[<currentTiddler>get[se-type]regexp<filterpattern>]" variable=patchworkTid
       emptyMessage="""<$macrocall $name=sectionizeSingleTiddler sourceTiddler=<<currentTiddler>> /> """ >
  <$macrocall $name=sectionizePatchworkTiddler sourceTiddler=<<patchworkTid>> />
</$list>
</$reveal>
</$list>

<!-- generate sections only by heading levels (h1, h2, h3, ...)

Note: this view template works with cascade new filter operator and uses $:/config/ViewTemplateBodyFilters/Sections
-->

I tried adding a list filter and transclude the Alternate editor tiddler with table in it , but that was not working. Any suggestions ?

I plan to create a button to add the field ae-type to tiddlers as I need (Similar to the JanJo section editor viewtoolbar button)

Theoretically, what you put in $:/plugins/arsheth/editor/viewtemplates/alternate editor will be displayed.

This code is little out of date, there is no need to check again if the tiddler has se-type field as the cascade already has done this!

This is to honor the fold state!

This is what it display instead of body

Is it needed in my case?

Can I just transclude the table tiddler here instead of the macrocall

No, it uses two states, you have one!

Sure, you can!

I use these four tiddlers, still nothing happens on adding the field ae-type to a tiddler by clicking the viewtoolbar button. @Mohammad Can you take at look this when free ?

<$list filter="[all[current]has:field[ae-type]]"> 
{{Alternate toggle editor}}
</$list>


[has:field[ae-type]!field:hide-body[yes]then[$:/plugins/arsheth/editor/viewtemplates/alternateeditor]]

This is the alternate editor table -

Here is a demo wiki - https://demowiki.tiddlyhost.com/

I have put all relevant tiddlers in the home page.

@arunnbabu81
As I understand, you like to show a tiddler as a table using viewtemplates (here cascades) and hide its content, am I right?

You are right. That table has editor on left side and preview on right side

Okay then lets first go through cascades

  1. you need to have a conditional viewtemplate, I see you have one My TiddlyWiki — a non-linear personal web notebook

add a list-before to it with value $:/config/ViewTemplateBodyFilters/default