Custom order of viewtemplate items?

Folks,

As you may be aware, it is possible to assign the $:/tags/ViewTemplate to a tiddler to make it appear on tiddlers, viewTemplate. You can wrap this in a condition to choose when to display it, you can also choose if it will or will not be hidden if the tiddler is folded/unfolded.

You can also make use of the list-before or list-after fields to position a tiddler within the viewTemplate or go ahead and reorder the elements with drag and drop using the $:/tags/ViewTemplate tag pill.

My Question;

Is there a way we could alter the order of the view template items appear on a specific tiddler rather than all tiddlers?

My thoughts;

  • perhaps an alternate viewTemplate would be needed
  • It seems to me a custom field on a tiddler could be used to;
    • sortby the custom field
    • a replacement list, then you could add and exclude viewTemplate items as well.
  • This may be good to add to the hackability of the view/edit template mechanism’s because at present no bespoke or interactive tiddler based ordering is possible.

Why?
In some cases we may have a button that results in a conditional element being displayed in the viewTemplate, however there may be a reason to alter the order they are displayed in different tiddlers, or a class of tiddlers.

For example imagine a large tiddler containing prose text, we may have a list of references we want to display. In some cases we would prefer this above the body text in others below.

Something similar would be helpful in the edit template for example to bring the edit fields list to the top when there is a lot of text, so you do not need to scroll. For example show the edit fields component above tiddlers whos text field exceeds 20,000 characters.

Presently to achieve this, you need to add additional items to the view or edit template and add appropriate conditions to both elements. This acts to bloat the size of the view/edit template rendering of every tiddler.

What are your thoughts?

Regards
Tones

I think that you are taking about Cascades mechanism without mentioning it.
https://tiddlywiki.com/#Cascades

1 Like

@Alvaro using the cascade mechanism may be part of a long term solution. At present the view and edit template tags allow you to sort template items globally, manually or influence with list-before and list-after. There is no way to do this by tiddler or conditionally.

Can you provide any more detail on how we may achieve it?

I was thinking about something similar to the example in the docs. https://tiddlywiki.com/#How%20to%20create%20a%20custom%20story%20tiddler%20template

You have to create a filter tiddler for story tiddler and an template tiddler. You can use a field to store the ordered list of fields or you can play with a tricky filter to reordering them (for example something like

[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]!has[draft.of]] [<currentTiddler>field:title[abc]then[$:/core/ui/ViewTemplate/subtitle]]

you can test it using it in the $:/core/ui/ViewTemplate. So the tiddler “abc” has the subtitle as last field in the viewtemplate)

2 Likes

I like your suggestion but would like to extend it so we had similar control as we currently have reordering the viewtemplate tags.

That is allow us to choose the specific order of all items with the viewtemplate without disrupting the normal view.

but;

  • it can be reorded on a specific tiddler only
  • or reorded only if a condition is true.

Perhaps a cascade can introduce a sortby operator or reference an alternate list to determin the order?

Thanks @Alvaro the quest continues

I don’t know if I understand you. I gave an basic example with only one dummy tiddler.

You have the general viewtemplate if its behaviour don’t match in your need, you have to options:

  • Modify the viewtemplate and specifically its filter.
  • Create(/clone) a new viewtemplate for each case where you have a custom filter. And then you can use the cascade mechanism.

I said this

thinking about use it in a filter exprexion.

You will always have to modify the filter in the used template. Cascade mechanism is to choose the template.

One dummy tiddler does not illustrate what I would like to build, an interactive " Custom order of viewtemplate items?" and I am trying to find a generic solution that everyone can make use of.

Are there other options?, that is my question.

Hence my call out for ideas and mechanism’s. You have raised some valid ones, thanks.

However I am seeking more ideas and dare I say a smart innovative way to achieve this, perhaps it could become a hackable feature in the standard distribution one day?

Here is my latest experiment, try on tiddlywiki.com

Stream of consciousness post

;Default order of items tagged <<tag $:/tags/ViewTemplate>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]]">

</$list>

<hr>
<$button >
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]]" variable="tag">
   <$action-listops $field="reorder" $subfilter=<<tag>>/>
</$list>
set reorder field from ~$:/tags/ViewTemplate
</$button> 

;Sorted by reorder
<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplate]sortby{!!reorder}]">

</$list>
;Draggable reorder
<$macrocall $name=list-links-draggable tiddler=<<currentTiddler>> field="reorder"/>

This allows us to set an alternative field as the sortby parameter.

  • The only issue is it needs to be set again if a new tiddler was tagged by $:/tags/ViewTemplate otherwise it will only appear at the top of the list.

Going further
my feeling is the same field/method that provides an alternative order, may also be a way to selectively include/exclude viewtemplate elements.

So the view template mechanism;
Checks to see if there is alternate list of viewtemplate elements defined in a macro

\define $:/tags/ViewTemplate() a b c
<<$:/tags/ViewTemplate>>

otherwise;

  • Checks to see if there is alternate list of viewtemplate elements locally defined on the current tiddler
{{!!$:/tags/ViewTemplate}}

otherwise;

  • Uses the existing method to list viewtemplate elements

hmmm