mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Add user documentation for cascade mechanism
This commit is contained in:
parent
edcba4ee16
commit
4514a67a1f
@ -1,6 +1,6 @@
|
||||
caption: 5.2.1
|
||||
created: 20211003152250369
|
||||
modified: 20211003152250369
|
||||
created: 20211206165748330
|
||||
modified: 20211206165748330
|
||||
tags: ReleaseNotes
|
||||
title: Release 5.2.1
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -17,18 +17,24 @@ type: text/vnd.tiddlywiki
|
||||
|
||||
The [[cascade mechanism|Cascades]] provides a flexible way to choose between multiple options. Crucially, it is done in a way that makes it simple for plugins to tweak the logic or add their own options.
|
||||
|
||||
Some of the things that can be done with cascades are:
|
||||
|
||||
* Replacing the default tiddler body template with a custom one for a certain type of tiddler
|
||||
* Giving all journal tiddlers a custom icon
|
||||
* Implementing a custom editor for certain types of tiddler
|
||||
|
||||
There are two parts to these changes. The underpinning is a new [[Cascade Filter Run Prefix]] that takes a list of filters and runs them in order, returning the result of the first one to return a value.
|
||||
|
||||
The second part is a series of improvements based on this new filter cascade mechanism. Conditional logic that was previously hidden within core templates can now be extended and tweaked much more easily than before.
|
||||
|
||||
Choosing the following elements of the core user interface is now handled with cascades:
|
||||
|
||||
* Story Tiddler Templates
|
||||
* Tiddler Colour
|
||||
* Tiddler Icons
|
||||
* View Template Body
|
||||
* View Template Title
|
||||
* Edit Template Body
|
||||
* [[Story Tiddler Templates|Story Tiddler Template Cascade]]
|
||||
* [[Tiddler Colour|Tiddler Colour Cascade]]
|
||||
* [[Tiddler Icons|Tiddler Icon Cascade]]
|
||||
* [[View Template Body|View Template Body Cascade]]
|
||||
* [[View Template Title|View Template Title Cascade]]
|
||||
* [[Edit Template Body|Edit Template Body Cascade]]
|
||||
|
||||
The cascades can be inspected in $:/ControlPanel under ''Info'' -> ''Advanced'' -> ''Cascades''.
|
||||
|
||||
|
47
editions/tw5.com/tiddlers/concepts/Cascades.tid
Normal file
47
editions/tw5.com/tiddlers/concepts/Cascades.tid
Normal file
@ -0,0 +1,47 @@
|
||||
created: 20211201100326006
|
||||
modified: 20211206164704335
|
||||
tags: Concepts
|
||||
title: Cascades
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
!! Introduction
|
||||
|
||||
Cascades are a key mechanism used to construct and customise TiddlyWiki's user interface.
|
||||
|
||||
<<.tip "See [[Customising TiddlyWiki's user interface]] for an overview of all the customisation mechanisms">>
|
||||
|
||||
!! How cascades work
|
||||
|
||||
Cascades provide a means to select one of multiple values based on flexible, extensible criteria. They can be thought of as a list of conditions that are evaluated in turn until one of them matches.
|
||||
|
||||
Each cascade is defined by a special tag which identifies the tiddlers containing the conditions to be matched. The [[Order of Tagged Tiddlers]] determines the order in which the conditions are processed, and provides the means for arranging new rules at specific points in the cascade.
|
||||
|
||||
The conditions are defined by a [[Filter Expression]] in the text field. The filters are evaluated with the list of input titles set to the title of the tiddler to be considered. The `currentTiddler` variable is also set to the title of the tiddler to be considered.
|
||||
|
||||
If the filter returns no result then that result will be ignored and the cascade proceeds to test the next condition. If the filter expression does return at least one result then it serves as the result of the entire cascade.
|
||||
|
||||
The [[Cascade Filter Run Prefix]] provides the implementation of the underlying logic.
|
||||
|
||||
!! Example
|
||||
|
||||
The [[Story Tiddler Template Cascade]] contains the logic for determining a tiddler should be displayed as an editable draft or in view mode. By default, it consists of two tiddlers containing the following list of rules:
|
||||
|
||||
# `[is[draft]then{$:/config/ui/EditTemplate}]` – if it is a draft tiddler, use the template title given in the tiddler $:/config/ui/EditTemplate
|
||||
# `[{$:/config/ui/ViewTemplate}] ` – otherwise, use the template title given in the tiddler $:/config/ui/ViewTemplate
|
||||
|
||||
!! Usage in the core
|
||||
|
||||
The TiddlyWiki core uses cascades to choose the following elements:
|
||||
|
||||
|[[Story Tiddler Template Cascade]] |The template used to display a particular tiddler in the story river. By default, the edit template is chosen for draft tiddlers, and the view template for others |
|
||||
|[[Tiddler Icon Cascade]] |The optional icon associated with a particular tiddler (displayed alongside the title) |
|
||||
|[[Tiddler Colour Cascade]] |The optional colour associated with a particular tiddler (used to colour the tiddler icon and if the tiddler is used as a tag also provides the colour for the tag pill) |
|
||||
|[[View Template Title Cascade]] |The template used to display the title of a particular tiddler (used by the default view template to display the tiddler title) |
|
||||
|[[View Template Body Cascade]] |The template used to display the view mode body of a particular tiddler (used by the default view template to display the tiddler body) |
|
||||
|[[Edit Template Body Cascade]] |The template used to display the edit mode body of a particular tiddler (used by the default edit template to display the tiddler body editor) |
|
||||
|
||||
You can see the current settings for each cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' tab.
|
||||
|
||||
!! See Also
|
||||
|
||||
<<list-links "[tag[Cascades]]">>
|
@ -1,8 +1,10 @@
|
||||
color: #FF8383
|
||||
created: 201308251447
|
||||
modified: 201308251447
|
||||
title: Concepts
|
||||
created: 20130825144700000
|
||||
list: Cascades ColourPalettes Commands [[Current Tiddler]] DataTiddlers [[Date Fields]] DefaultTiddlers DictionaryTiddlers ExternalImages Filters [[Hard and Soft Links]] JSONTiddlers [[Keyboard Shortcut Tiddler]] Macros Messages Modules PermaLinks Plugins Pragma [[Railroad Diagrams]] ShadowTiddlers [[Story River]] SystemTags SystemTiddlers Tagging TemplateTiddlers TextReference TiddlerFields TiddlerLinks Tiddlers TiddlyWiki TiddlyWiki5 [[Title List]] [[Title Selection]] Transclusion Variables Widgets Wiki WikiText
|
||||
modified: 20211201100624625
|
||||
tags: Reference
|
||||
title: Concepts
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
These are the concepts underlying TiddlyWiki. Understanding how these ideas fit together is the key to getting the most from TiddlyWiki.
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
created: 20211206161652630
|
||||
modified: 20211206161959460
|
||||
tags: Cascades
|
||||
title: Edit Template Body Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The edit template body cascade is a [[cascade|Cascades]] used by the default edit template to choose the template for displaying the tiddler body.
|
||||
|
||||
The default edit template body cascade consists of:
|
||||
|
||||
# If the tiddler has the field ''_canonical_uri'' then use the template $:/core/ui/EditTemplate/body/canonical-uri to display the remote URL
|
||||
# Otherwise, use the template $:/core/ui/EditTemplate/body/default which provides the default editing interface
|
||||
|
||||
You can see the current settings for the view template body cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Edit Template Body'' tab.
|
||||
|
||||
<<list-links "[tag[Edit Template Body Cascade]]">>
|
@ -0,0 +1,16 @@
|
||||
created: 20211206132047986
|
||||
modified: 20211206155818924
|
||||
tags: Cascades
|
||||
title: Story Tiddler Template Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The story tiddler template cascade is a [[cascade|Cascades]] used to choose which [[Story Tiddler Template]] should be used for a particular tiddler.
|
||||
|
||||
The default story tiddler template cascade consists of:
|
||||
|
||||
# If the tiddler is a draft tiddler, use the template title given in the tiddler $:/config/ui/EditTemplate
|
||||
# Otherwise, use the template title given in the tiddler $:/config/ui/ViewTemplate
|
||||
|
||||
You can see the current settings for the story tiddler template cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Story Tiddler'' tab.
|
||||
|
||||
<<list-links "[tag[Story Tiddler Template Cascade]]">>
|
@ -0,0 +1,13 @@
|
||||
created: 20211204122044198
|
||||
modified: 20211206133756716
|
||||
tags: Concepts
|
||||
title: Story Tiddler Template
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
"Story tiddler template" refers to the template used to display a tiddler within the story river.
|
||||
|
||||
The [[Story Tiddler Template Cascade]] is used to choose the template to be used for a particular tiddler. By default, the edit template is used for tiddlers in draft mode, and the view template used otherwise.
|
||||
|
||||
See also:
|
||||
|
||||
<<list-links "[tag[Story Tiddler Template]]">>
|
@ -0,0 +1,16 @@
|
||||
created: 20211206160300525
|
||||
modified: 20211206165301231
|
||||
tags: Cascades
|
||||
title: Tiddler Colour Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The tiddler colour cascade is a [[cascade|Cascades]] used to choose which colour should be used for a particular tiddler.
|
||||
|
||||
The default tiddler colour cascade consists of:
|
||||
|
||||
# If the tiddler has a ''color'' field, use the value as the colour
|
||||
# If the tiddler $:/config/DefaultTiddlerColour exists, use the value as the colour
|
||||
|
||||
You can see the current settings for the tiddler colour cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Colour'' tab.
|
||||
|
||||
<<list-links "[tag[Tiddler Colour Cascade]]">>
|
16
editions/tw5.com/tiddlers/concepts/Tiddler Icon Cascade.tid
Normal file
16
editions/tw5.com/tiddlers/concepts/Tiddler Icon Cascade.tid
Normal file
@ -0,0 +1,16 @@
|
||||
created: 20211206154017669
|
||||
modified: 20211206160003647
|
||||
tags: Cascades
|
||||
title: Tiddler Icon Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The tiddler icon cascade is a [[cascade|Cascades]] used to choose which icon should be used for a particular tiddler.
|
||||
|
||||
The default tiddler icon cascade consists of:
|
||||
|
||||
# If the tiddler has an ''icon'' field, use the value as the title of the icon tiddler
|
||||
# If the tiddler $:/config/DefaultTiddlerIcon exists, use the value as the title of the icon tiddler
|
||||
|
||||
You can see the current settings for the tiddler icon cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''Tiddler Icon'' tab.
|
||||
|
||||
<<list-links "[tag[Tiddler Icon Cascade]]">>
|
@ -0,0 +1,19 @@
|
||||
created: 20211206161124327
|
||||
modified: 20211206161613268
|
||||
tags: Cascades
|
||||
title: View Template Body Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The view template body cascade is a [[cascade|Cascades]] used by the default view template to choose the template for displaying the tiddler body.
|
||||
|
||||
The default view template body cascade consists of:
|
||||
|
||||
# If the tiddler title starts with any of a list of known system tiddler prefixes, use the template $:/core/ui/ViewTemplate/body/code to display the body as preformatted code
|
||||
# If the tiddler has the field ''plugin-type'' set to ''import'' then use the template $:/core/ui/ViewTemplate/body/import which displays the custom import user interface
|
||||
# If the tiddler has the field ''plugin-type'' then use the template $:/core/ui/ViewTemplate/body/plugin to display the plugin information badge
|
||||
# If the tiddler has the field ''hide-body'' set to ''yes'' then use the template $:/core/ui/ViewTemplate/body/blank to hide the body
|
||||
# Otherwise, use the default template $:/core/ui/ViewTemplate/body/default
|
||||
|
||||
You can see the current settings for the view template body cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''View Template Body'' tab.
|
||||
|
||||
<<list-links "[tag[View Template Body Cascade]]">>
|
@ -0,0 +1,16 @@
|
||||
created: 20211206160703815
|
||||
modified: 20211206161115837
|
||||
tags: Cascades
|
||||
title: View Template Title Cascade
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The view template title cascade is a [[cascade|Cascades]] used by the default view template to choose the template for displaying the tiddler title.
|
||||
|
||||
The default view template title cascade consists of:
|
||||
|
||||
# If the tiddler title starts with `$:/` then use the template $:/core/ui/ViewTemplate/title/system which causes the `$:/` prefix to be displayed in pale text
|
||||
# Otherwise, use the template $:/core/ui/ViewTemplate/title/default which displays the title in plain text
|
||||
|
||||
You can see the current settings for the view template title cascade in $:/ControlPanel under the ''Info'' -> ''Advanced'' -> ''Cascades'' -> ''View Template Title'' tab.
|
||||
|
||||
<<list-links "[tag[View Template Title Cascade]]">>
|
@ -1,6 +1,6 @@
|
||||
created: 20140904101600000
|
||||
list: [[Adding a table of contents to the sidebar]] [[Alternative page layouts]] [[Configuring startup tiddlers]] [[Configuring the default TiddlerInfo tab]] [[Creating a custom export format]] [[Creating a splash screen]] [[Creating new toolbar buttons]] [[Customising search results]] [[Customising TiddlyWiki's user interface]] [[Hidden Settings]] [[How to add a new tab to the sidebar]] [[How to apply custom styles]] [[How to create keyboard shortcuts]] [[How to turn off camel case linking]] [[How to widen tiddlers (aka storyriver)]] [[Making a custom journal button]] [[Preserving open tiddlers at startup]] [[Setting a favicon]] [[Setting a page background image]] [[Using Stylesheets]]
|
||||
modified: 20211127140430506
|
||||
list: [[Adding a table of contents to the sidebar]] [[Alternative page layouts]] [[Configuring startup tiddlers]] [[Configuring the default TiddlerInfo tab]] [[Creating a custom export format]] [[Creating a splash screen]] [[Creating new toolbar buttons]] [[Customising search results]] [[Customising TiddlyWiki's user interface]] [[Hidden Settings]] [[How to add a new tab to the sidebar]] [[How to apply custom styles]] [[How to create a custom story tiddler template]] [[How to create a custom tiddler icon rule]] [[How to create a custom tiddler colour rule]] [[How to create keyboard shortcuts]] [[How to turn off camel case linking]] [[How to widen tiddlers (aka storyriver)]] [[Making a custom journal button]] [[Preserving open tiddlers at startup]] [[Setting a favicon]] [[Setting a page background image]] [[Using Stylesheets]]
|
||||
modified: 20211206162235300
|
||||
tags: TableOfContents
|
||||
title: Customise TiddlyWiki
|
||||
type: text/vnd.tiddlywiki
|
||||
|
@ -1,5 +1,5 @@
|
||||
created: 20211127084727217
|
||||
modified: 20211128200929866
|
||||
modified: 20211204120054422
|
||||
tags: [[Customise TiddlyWiki]]
|
||||
title: Customising TiddlyWiki's user interface
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -11,6 +11,7 @@ Several different mechanisms are used to achieve this:
|
||||
* special fields
|
||||
* special titles
|
||||
* special tags
|
||||
* cascades
|
||||
|
||||
Here we provide an overview of those mechanisms and how they relate together.
|
||||
|
||||
@ -53,3 +54,22 @@ See SystemTags for details of all the special tags.
|
||||
The entire TiddlyWiki user interface is constructed from lists formed from special system tags.
|
||||
|
||||
The ordering of these lists is determined by the [[order of tagged tiddlers|Order of Tagged Tiddlers]] rules. Users can re-order tags using drag and drop within a tag dropdown.
|
||||
|
||||
!! Cascades
|
||||
|
||||
Cascades provide a means to select one of multiple values based on flexible, extensible criteria. They can be thought of as a list of conditions that are evaluated in turn until one of them matches.
|
||||
|
||||
For example, the core uses the template $:/core/ui/ViewTemplate to display tiddlers in view mode, and $:/core/ui/EditTemplate to display tiddlers in edit mode. A cascade is used to choose which template to use for a particular tiddler:
|
||||
|
||||
# If the tiddler is a draft, then use $:/core/ui/EditTemplate
|
||||
# Otherwise, use $:/core/ui/EditTemplate
|
||||
|
||||
The list of conditions is defined via a special tag, making it possible to insert additional conditions anywhere in the list.
|
||||
|
||||
For example, a plugin might add a special template $:/plugins/example/map-template for tiddlers that have the tag [[$:/tags/Map]] by inserting an additional rule:
|
||||
|
||||
# If the tiddler is a draft, then use $:/core/ui/EditTemplate
|
||||
# @@background: yellow; If the tiddler is tagged $:/tags/Map, then use $:/plugins/example/map-template@@
|
||||
# Otherwise, use $:/core/ui/EditTemplate
|
||||
|
||||
See [[Cascades]] for more details.
|
@ -1,7 +1,10 @@
|
||||
title: Demo Tiddler List with Custom Story Tiddler Template
|
||||
tags: $:/tags/TiddlerList
|
||||
created: 20211204122107920
|
||||
filter: HelloThere Community GettingStarted Features Reference Plugins Learning
|
||||
modified: 20211204131610322
|
||||
tags: $:/tags/TiddlerList
|
||||
title: Demo Tiddler List with Custom Story Tiddler Template
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
This is a demo tiddler with a custom story tiddler template that displays the tiddlers named in the list field as a fan.
|
||||
|
||||
See [[Story Tiddler Templates]] for details.
|
||||
See [[How to create a custom story tiddler template]] for details.
|
||||
|
@ -1,5 +1,9 @@
|
||||
title: $:/_tw5.com/CustomTiddlerColourCascadeDemo
|
||||
created: 20211206114433294
|
||||
list-before: $:/config/TiddlerColourFilters/default
|
||||
modified: 20211206114433294
|
||||
tags: $:/tags/TiddlerColourFilter
|
||||
title: $:/_tw5.com/CustomTiddlerColourCascadeDemo
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
[tag[TableOfContents]then[#1e90ff]]
|
||||
[tag[Working with TiddlyWiki]then[darkorchid]]
|
||||
|
@ -1,5 +1,9 @@
|
||||
title: $:/_tw5.com/CustomTiddlerIconCascadeDemo
|
||||
created: 20211205195110592
|
||||
list-before: $:/config/TiddlerIconFilters/default
|
||||
modified: 20211205195217941
|
||||
tags: $:/tags/TiddlerIconFilter
|
||||
title: $:/_tw5.com/CustomTiddlerIconCascadeDemo
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
[tag[TableOfContents]then[$:/core/images/globe]]
|
||||
[tag[Working with TiddlyWiki]then[$:/core/images/help]]
|
||||
|
@ -9,19 +9,19 @@ type: text/vnd.tiddlywiki
|
||||
|
||||
The <<.op ":cascade">> filter run prefix is used by the ~TiddlyWiki core to choose the colour for each tiddler as used in the tag pill generated by the tag macro.
|
||||
|
||||
`:cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]]`
|
||||
`:cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]]`
|
||||
|
||||
The filter expression inside the above <<.op :cascade>> filter run returns a list of filters from the text fields of tiddlers tagged <<tag $:/tags/TiddlerColourFilter>> as shown below:
|
||||
|
||||
<ul>
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]]">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]]">
|
||||
<li><pre><$text text=<<currentTiddler>>/></pre></li>
|
||||
</$list>
|
||||
</ul>
|
||||
|
||||
For each input title, each of these filters is now applied to in turn until the first filter that returns a non-empty list. The first result from this non-empty list replaces that input title and is used as the colour for that tiddler.
|
||||
|
||||
<<.operator-example 1 """[all[shadows+tiddlers]] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]] +[!is[blank]limit[10]]""">>
|
||||
<<.operator-example 1 """[all[shadows+tiddlers]] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] +[!is[blank]limit[10]]""">>
|
||||
|
||||
!! Extended example
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
created: 20211204120244761
|
||||
modified: 20211206165108185
|
||||
tags: Learning Cascades [[Story Tiddler Template]] [[Story Tiddler Template Cascade]] [[Customise TiddlyWiki]]
|
||||
title: How to create a custom story tiddler template
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
Here we show how to add a rule to the [[Story Tiddler Template Cascade]] that causes tiddlers tagged <<tag "$:/tags/TiddlerList">> to be displayed with a custom appearance incorporating thumbnails of the tiddlers named in the list field.
|
||||
|
||||
Open [[Demo Tiddler List with Custom Story Tiddler Template]] to see the demo.
|
||||
|
||||
First, we add a new step to the story tiddler template cascade. The new filter step is:
|
||||
|
||||
```
|
||||
[tag[$:/tags/TiddlerList]then[$:/_tw5.com/CustomStoryTiddlerTemplateDemo/Template]]
|
||||
```
|
||||
|
||||
It can be read as:
|
||||
|
||||
```
|
||||
If the tiddler has the tag $:/tags/TiddlerList then return $:/_tw5.com/CustomStoryTiddlerTemplateDemo/Template
|
||||
```
|
||||
|
||||
> The template $:/_tw5.com/CustomStoryTiddlerTemplateDemo/Template also depends on styles defined in [[$:/_tw5.com/CustomStoryTiddlerTemplateDemo/Styles]].
|
||||
|
||||
The story tiddler template cascade is defined by the tag <<tag "$:/tags/StoryTiddlerTemplateFilter">>, so we need to create a configuration tiddler with that tag.
|
||||
|
||||
We also need to make sure that it is inserted at the correct point in the cascade:
|
||||
|
||||
* The new rule must be after the "draft" rule to ensure that draft tiddlers with the tag $:/tags/TiddlerList can be edited
|
||||
* The new rule must be before the "default" rule otherwise it will never be executed
|
||||
|
||||
The control panel "Cascades" tab shows that this can be achieved by inserting the new step immediately before the default step using the `list-before` field.
|
||||
|
||||
The full list of fields in the configuration tiddler is:
|
||||
|
||||
<<.tiddler-fields "$:/_tw5.com/CustomStoryTiddlerTemplateDemo/Filter">>
|
||||
|
||||
Finally, we need to create the demo tiddler itself:
|
||||
|
||||
<<.tiddler-fields "Demo Tiddler List with Custom Story Tiddler Template">>
|
@ -0,0 +1,36 @@
|
||||
created: 20211206114114698
|
||||
modified: 20211206165150302
|
||||
tags: Learning Cascades [[Customise TiddlyWiki]]
|
||||
title: How to create a custom tiddler colour rule
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
Here we show how to add a rule to the [[Tiddler Colour Cascade]] that causes tiddlers with the tag <<tag "TableOfContents">> to be given a bright blue colour and tiddlers with the tag <<tag "Working with TiddlyWiki">> to be given a dark purple colour.
|
||||
|
||||
<<.tip "[[How to create a custom tiddler icon rule]] describes how the same tiddlers have been given a custom icon">>
|
||||
|
||||
First, we add a new step to the tiddler colour cascade. The new filter step is:
|
||||
|
||||
```
|
||||
[tag[TableOfContents]then[#1e90ff]]
|
||||
[tag[Working with TiddlyWiki]then[darkorchid]]
|
||||
```
|
||||
|
||||
It can be read as:
|
||||
|
||||
```
|
||||
If the tiddler has the tag "TableOfContents" then return the colour #1e90ff
|
||||
Else if the tiddler has the tag "Working with TiddlyWiki" then return the colour darkorchid
|
||||
```
|
||||
|
||||
The tiddler colour cascade is defined by the tag <<tag "$:/tags/TiddlerColourFilter">>, so we need to create a configuration tiddler with that tag.
|
||||
|
||||
We also need to make sure that it is inserted at the correct point in the cascade:
|
||||
|
||||
* The new rule must be after the "colour-field" rule to ensure that tiddlers with an explicit ''color'' field will respect the value of that field
|
||||
* The new rule must be before the "default" icon otherwise it will never be seen if the default colour is specified
|
||||
|
||||
The control panel "Cascades" tab shows that this can be achieved by inserting the new step immediately before the default step using the `list-before` field.
|
||||
|
||||
The full list of fields in the configuration tiddler is:
|
||||
|
||||
<<.tiddler-fields "$:/_tw5.com/CustomTiddlerColourCascadeDemo">>
|
@ -0,0 +1,36 @@
|
||||
created: 20211204161649863
|
||||
modified: 20211206165129215
|
||||
tags: Learning Cascades [[Tiddler Icon Cascade]] [[Customise TiddlyWiki]]
|
||||
title: How to create a custom tiddler icon rule
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
Here we show how to add a rule to the [[Tiddler Icon Cascade]] that causes tiddlers with the tag <<tag "TableOfContents">> to be given the "globe" icon <<.icon $:/core/images/globe>> and tiddlers with the tag <<tag "Working with TiddlyWiki">> to be given the "help" icon <<.icon $:/core/images/help>>.
|
||||
|
||||
<<.tip "[[How to create a custom tiddler colour rule]] describes how the same tiddlers have been given a custom colour">>
|
||||
|
||||
First, we add a new step to the tiddler icon cascade. The new filter step is:
|
||||
|
||||
```
|
||||
[tag[TableOfContents]then[$:/core/images/globe]]
|
||||
[tag[Working with TiddlyWiki]then[$:/core/images/help]]
|
||||
```
|
||||
|
||||
It can be read as:
|
||||
|
||||
```
|
||||
If the tiddler has the tag "TableOfContents" then return $:/core/images/globe
|
||||
Else if the tiddler has the tag "Working with TiddlyWiki" then return $:/core/images/help
|
||||
```
|
||||
|
||||
The tiddler icon cascade is defined by the tag <<tag "$:/tags/TiddlerIconFilter">>, so we need to create a configuration tiddler with that tag.
|
||||
|
||||
We also need to make sure that it is inserted at the correct point in the cascade:
|
||||
|
||||
* The new rule must be after the "icon-field" rule to ensure that tiddlers with an explicit ''icon'' field will respect the value of that field
|
||||
* The new rule must be before the "default" icon otherwise it will never be seen if the default icon is specified
|
||||
|
||||
The control panel "Cascades" tab shows that this can be achieved by inserting the new step immediately before the default step using the `list-before` field.
|
||||
|
||||
The full list of fields in the configuration tiddler is:
|
||||
|
||||
<<.tiddler-fields "$:/_tw5.com/CustomTiddlerIconCascadeDemo">>
|
Loading…
Reference in New Issue
Block a user