Question
Hi,
I'm trying to hide the Wysiwyg button in the pattern template, and only show it when COMPOSER=kupu is set in the topic.
I've tried using several incarnations of an %IF statement in viewtoolbar.pattern.tmpl, but until now without luck.
I ended with:
%IF{"$ COMPOSER='kupu' and WysiwygPluginEnabled" then="<span class="patternButton"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?cover=%COMPOSER%&t=%GMTIME{"$epoch"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='w'>&WYSIWYG"}%
I tested that the first part of the %IF works (by replacing the THEN part with a text).
But I can't find a way to get a TMPL:P or button definition to work. Any ideas? I can offer to document this if I can get it to work...
Environment
--
JosMaccabiani - 02 Jun 2007
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
This solution works, but is not very nice:
%IF{"$ COMPOSER='kupu' and WysiwygPluginEnabled" then="<span class='patternButton'><a href='%SCRIPTURL{edit}%/%WEB%/%TOPIC%?cover=%COMPOSER%&t=%GMTIME{$epoch}%' rel='nofollow'>WYSIWYG</a></span>"}%
ArthurClemens pointed me to some ideas for making a nicer solution, which I'll post here as well if I can get them to work.
--
JosMaccabiani - 02 Jun 2007
--
JosMaccabiani - 02 Jun 2007
Some docco for potential inclusion in
PatternSkinCustomisation
I only want to see the WYSIWYG button when the topic sets the COMPOSER variable
I you've installed and enabled the
WysiwygPlugin, but only want to show the action button on pages where the variable COMPOSER has been explicitly set to one of the wysiwyg editors, then the following customisation might help you. Using either a template or a topic template, write in your custom template:
%TMPL:INCLUDE{"view"}%
This first part conditionally removes the WYSIWYG button at the top of the page:
%TMPL:DEF{toolbar_buttons}%<div class="patternToolBarButtons">
<span class="patternButton">%TMPL:P{"activatable_edit_or_create"}%</span>
%IF{"$ COMPOSER='kupu' or $ COMPOSER='wikiwyg' and WysiwygPluginEnabled" then="<span class='patternButton'><a href='%SCRIPTURL{edit}%/%WEB%/%TOPIC%?cover=%COMPOSER%&t=%GMTIME{$epoch}%' rel='nofollow'>WYSIWYG</a></span>"}%
<span class="patternButton">%TMPL:P{"activatable_attach"}%</span>
<span class="patternButton">%TMPL:P{"printable"}%</span>
</div>%TMPL:END%
Also, you'd like to conditionally remove the link in the bottom toolbar. So in your new skin file, also override the topicactionbuttons definition:
%TMPL:DEF{"topicactionbuttons"}%
%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"sep"}%
%IF{"$ COMPOSER='kupu' or $ COMPOSER='wikiwyg' and WysiwygPluginEnabled" then="<a href='%SCRIPTURL{edit}%/%WEB%/%TOPIC%?cover=%COMPOSER%&t=%GMTIME{$epoch}%' rel='nofollow'>WYSIWYG</a><span class='twikiSeparator'> | </span>"}%
%TMPL:P{"activatable_attach"}%%TMPL:P{"sep"}%
%TMPL:P{"printable"}%%TMPL:P{"raw_or_view"}%%TMPL:P{"sep"}%
%TMPL:P{"backlinks"}%%TMPL:P{"sep"}%
%TMPL:P{"revisions"}%%TMPL:P{"sep"}%
%TMPL:P{"activatable_more"}%%TMPL:END%
Make sure that everything between %TMPL:DEF and %TMPL:END is on the same line, so remove newlines when copy/pasting.
Make sure to enable your new skin in
TWikiPreferences! If everything went all right, you:
- should not see any WYSIWYG buttons in the toolbars on most topics
- should see the links when the topic contains
Set COMPOSER='kupu'
--
JosMaccabiani - 02 Jun 2007
Created
Bugs:Item4193
to track this
--
JosMaccabiani - 02 Jun 2007
I was surprised when you asked, to find that the twiki templates currently use the
WysiwygEnabled context, as that isn't particularly flexible as you found.
I wonder if we're not better off changing the skins to test for the Setting of the
COMPOSER variable, and to default that variable to an IF that tests
WysiwygPluginEnabled. Then your requirement would be met by
just setting
COMPOSER to blank in the TWiki Prefs.
--
SvenDowideit - 02 Jun 2007
That is a good suggestion. And implemented.
--
ArthurClemens - 02 Jun 2007