Hi, I’ve written a theme-switching button, using this button, I could change the whole theme of tiddlywiki, including background image and palette, the question is, I click it within the tiddler, that button works well, but when i tagged that tiddler with “$:/tags/PageControls” so I could click that button on control bar, it not works. I know I must miss something, but I just cannot figure it out, Does anybody have met this similar situation or can you give me any clues? (code is too long, but if you want to give it a look, I will paste it here later.)
Without seeing the code, it’s somewhat difficult to properly diagnose what might be going wrong.
However… based on the reported symptom that the code works in a tiddler but not in the sidebar, it should be noted that within a tiddler the <<currentTiddler>>
variable has a value equal to the title of the containing tiddler, but in the sidebar the <<currentTiddler>>
variable has NO value.
Thus, if your code depends upon the value of <<currentTiddler>>
or any implied reference to it, such as “{{!!fieldname}}
”, then it won’t work in the sidebar.
Hope this helps,
-e
P.S. Please post your code, even it it is long. Alternatively, upload your entire TiddlyWiki to somewhere such as http://TiddlyHost.com so we can look as it “in situ”.
Hi, thank you, buddy! it really works, as you say, I changed currentTiddler
value to the tiddler where the button is located, then it works well too on control bar. Here is the code if you are interested:
<$let
currentTiddler="$:/plugins/uzvg/ui/Buttons/SwitchPalette"
darkPalette={{!!dark-palette}}
lightPalette={{!!light-palette}}
PaletteTid="$:/palette"
BackgroundImageTid="$:/themes/tiddlywiki/vanilla/settings/backgroundimage"
GiscusThemeTid="$:/config/giscus/theme" >
<$button tooltip={{$:/language/Buttons/Shiraz/Hint}} aria-label={{$:/language/Buttons/Shiraz/Caption}} class=<<tv-config-toolbar-class>> >
<$list filter="[<tv-config-toolbar-icons>match[yes]]">
{{$:/plugins/kookma/shiraz/images/palette-switch}}
</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]">
<span class=tc-btn-text>switch palettes</span>
</$list>
<$reveal state="$:/palette" text=<<darkPalette>> type="match">
<<LightenSwitch>>
</$reveal>
<$reveal state="$:/palette" text=<<darkPalette>> type="nomatch">
<<DarkenSwitch>>
</$reveal>
</$button>
</$let>