TiddlyWiki - Alternative Page Layout

Advance apologies for what may be a hopelessly naive question - I have consulted the doc that I could find but I couldn’t find answers.

Question: Could the new alternative page layout system ( New in: 5.1.23 ) have provision for an alternative tiddler template so that not only the way the page is displayed is swap-able but also the way tiddlers appear can be swapped at the same time - could each alternative page layout carry a ‘payload’ of a tiddler template for use with that page layout?

https://tiddlywiki.com/prerelease/static/Alternative%20page%20layouts.html

Example: Instead of main tiddler text show content of a hand edited custom tiddler field called summary - good for exam revision type work - learn or revise the full tiddler contents in the standard page layout and then flip over to an alternative page layout called ‘summary’ to test recall given only a brief summary for each tiddler.

That strikes me as very powerful is it feasible or perhaps already available?

1 Like

The mechanism for change the tiddler template is the cascades. You can use it with/without change of layout, you only need to create a specific filter expression.

For example, if you want change the (story) template of all tiddlers to MyTiddlerTemplate when you swap the layout (AlternativeLayout), you could use something like (I don’t test it)

[[$:/layout]contains:text[AlternativeLayout]then[MyTiddlerTemplate] 

More hints here → https://tiddlywiki.com/#Cascades:Cascades%20[[How%20to%20create%20a%20custom%20story%20tiddler%20template]]

As @Alvaro says you can do this via the cascade mechanism, I would suggest you use something to indicate tiddlers to be treated differently not to all tiddler, for example this is not relevant to the control panel etc…

  • In the recent past we may have set the hide-body (field) to Yes and used a view template to display the “summary” and toggle the display of the body instead.

Basically, yes you could do as you ask, but its not the best approach in my view.

If you learn how TiddlyWiki starts with the page layout, loading all its elements, such as the sidebar, story etc… and the story applies the view/edit templates to each tiddler in the story you will see it is quite involved.

There are many opportunities to alter the way content is presented within the standard layout, but making use of the “Alternative Page Layout” is another, but alt-layouts are possibly best used when making broad changes to the page layout, otherwise you have to do a lot more work, or reuse the same layout when you can just modify something in the “standard layout”.

I recommend you develop this summary/full view mechanism only for a subset of tiddlers eg with a tag or field “object-type” set to “flash-card” or something.

Have you searched for existing flashcard solutions?, others have done this for learning, spaced repetition learning, tiddlers as cards with “two sides”.

Thanks TW_Tones.

The flashcard was simply a hypothetical example for illustration purposes, what I am interested in here is the generality of being able to swap at will the tiddler template to be used in conjunction with all my existing custom controls that I use to fill the story river - individual tag pill buttons, filters, searches etc - being able to swap the story river tiddler appearance irrespective of which filter or action had populated the story river.

As you say the existence of a “flash-card” field might be used to trigger a different tiddler template as indeed the current system uses for “draft” but I was looking for a general solution where the condition for displaying the tiddler one way or another may have no relationship to specific fields or qualities of the tiddler other than as you point out it is not a system tiddler.

I think that is really the essence of the difference here and what started me thinking about the new page layout option, namely that the criteria for deciding how to do layout is configured for a real time arbitary user decision expressed in the interface rather than acting on a quality contained in the object being rendered.

Someone else looking at the code structure might regard tiddler layout and page layout as two different beasts but from a user perspective I saw them as very close cousins - it seemed natural to me that anyone interested in swapping the page layout might be interested in swapping tiddler layout at the same time. The idea of the page layout options being one half of a broader option to alter page layout and tiddler layout made perfect sense to me so I was putting out feelers for whether the page layout initiative was extendable.

I think, what you request here is a Theme. Themes are plugins, that can allow you to add and remove payload, with a toggle-like function.

So the default theme can have your default experience. The summary theme can have new tiddler templates as a payload that will be activated with the theme.

The only new thing you probably want is a new theme switcher that can be activated in the same way as the layout switcher.

1 Like

Thanks Mario - I had better take a look at themes :grinning: if after playing around with themes and gaining some experience it turned out to be the solution then yes the ideal would be to be able to swap themes quickly and easily as with the layout switcher.

TiddlyWikis User interface UI is more extensible than you can imagine, and each time we come across a need for more flexibility we add it.

Perhaps the first thing to do is learn about the new cascade methods Control Panel > Info > Advanced > Cascades

  • Story Tiddler is the whole visible tiddler
  • View Template Body is the body/text part.

There is value undertaking a self guided search inside any copy of tiddlywiki to see how it works. Even if you made a new page layout you would most likely reuse the existing code in the story and view/edit templates.

Here is a quick summary (although the cascades now influence this)

  • $:/core/ui/PageTemplate uses Items tagged $:/tags/PageTemplate construct the whole page - clone $:/core/ui/PageTemplate to switch page layouts
    • One of these is $:/core/ui/PageTemplate/story that list all open items in the story using $:/core/ui/StoryTiddlerTemplate (and above an below story items)
      • $:/config/ui/ViewTemplate then $:/core/ui/ViewTemplate by default renders each tiddler in the story making use of $:/tags/ViewTemplate this is the whole tiddler view.
        • One of these is $:/core/ui/ViewTemplate/body that displays the text field after rendering. This is just the rendering of the body or text field.

Even if you do something that changes how ALL tiddlers or a subset of tiddlers are displayed differently eg [all[current]!is[system]] I recommend you allow your self to switch back to default behaviour.