Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x01x01
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, lots more
Server OS: RH ES
Web server: Apache 2.052
Perl version: 5.8.5
Client OS: winxp
Web Browser: Ie7 & Firefox 2
Categories: Plugins, Skin

-- JosMaccabiani - 02 Jun 2007

Answer

ALERT! 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'>&nbsp;|&nbsp;</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

Change status to:
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2007-06-02 - ArthurClemens
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.