How can we determine if a tiddler was transcluded in view or edit templates? and/or more than view/edit modes?

Folks,

How can we determine if a tiddler was transcluded in view or edit templates?

It seems to me it would be nice if I could write a single button tiddler that can respond differently if tiddler was transcluded in either the view or edit templates?

see my recent button drop down and template Toolbar - custom button opening dropdown menu - #4 by TW_Tones

  • I would like it to list different items if this same button is displayed in the view or edit mode.

It seems a variable may be a useful to add to the view/edit template process for such cases.

More than view/edit modes?
If we are looking to pass on which mode the current tiddler is in, it seems to me, along with the new cascade facilities it would be nice to be able to introduce other modes, In particular I would like an update mode that uses a form of view template but in which you can edit the content of the current tiddler.

  • If we do this it could just be an alternate body but perhaps more
  • If using a mode it would be nice if it could be overridden with a field on the current tiddler or variable and if not use a global mode.
  • It may be practical to have some parallel modes as well eg: editing (mode) as a designer not user (mode)

Thanks for your ideas.

Post Script
This macro <<mydumpvariables>> can help in this research my-custom-dumpvariables.json (672 Bytes)

Maybe the QualifyWidget?

twMat how do you suggest?

Are you saying the result is different because of position in the widget tree? How can we use it?

It is late so I’m not really saying anything but just IF you hadn’t considered that widget then just maybe it has something to do with this. Sorry I should have been clearer that I had no specific solution in mind.

Looking inside $:/core/modules/widgets/list.js we see the section “Compose the template for a list item” which is using the presence of the “draft.of” field.

So the following works, at least to choose between view and edit
{{{ [all[current]has[draft.of]then[edit]else[view]] }}}

So we can answer

How can we determine if a tiddler was transcluded in view or edit templates?

  • by testing for the existence of the draft.of field, exist then edit else view

We also have available

  • The title (draft is diferent)
  • draft.title field
  • aforementioned draft.of field
  • Also is[draft] filter operator
<$list filter="[all[current]is[draft]]">
   Edit mode
</$list>
<$list filter="[all[current]!is[draft]]">
   View mode
</$list>

more than view/edit modes?

I think it may be clear other modes must exist within the view template handling.