Tags:
forms1Add my vote for this tag twistyplugin1Add my vote for this tag create new tag
view all tags

Question

If a page has a form, I would like to wrap the form in a Twisty on View.

I thought to duplicate the way the twisty wrapping of the attachments table is done but I'm a bit confused.

I see where the view.pattern.tmpl shows the form.

%TMPL:DEF{"form"}%%META{"form"}%%TMPL:END%
%TMPL:DEF{"formattop"}%%TMPL:END%
%TMPL:DEF{"formatbottom"}%%TMPL:P{"form"}%%TMPL:END%

I have tried simply putting a TWISTY into the

%TMPL:DEF{"form"}%

but that fires even if there is no form.

I want to see the TWISTY if there is a form and not if there isn't. I'm stumped.

I tried

TMPL:DEF{"form"}% %META{"form"}% %TMPL:END%
%TMPL:DEF{"topicformtwisty"}%%TWISTY{ mode="div" showlink="Show Form" hidelink="Hide Form" showimgleft="%ICONURLPATH{toggleopen-small}%" hideimgleft="%ICONURLPATH{toggleclose-small}%" }%
%META{"form"}%
%ENDTWISTY%
%TMPL:END%

%TMPL:DEF{"formattop"}%%TMPL:END%

%TMPL:DEF{"formatbottom"}% 
%IF{" '%TMPL:P{"form"}%' = '' " then="" else="%TMPL:P{"topicformtwisty"}%"}% 
%TMPL:END%

but the %IF is failing.

How do I test IF there is a form...?

Environment

TWiki version: unspecified
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Forms, Templates , TwistyPlugin

-- VickiBrown - 14 Aug 2008

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.

The attachment twisty is located in attachtables.pattern.tmpl. Likewise a form twisty must go into formtables.pattern.tmpl. The code then looks like this:

%{ These templates define the form attached at the bottom of viewed page. }%


%TMPL:DEF{"starttopicformwisty"}%%TWISTY{id="topicformlist" mode="div" remember="on" link="%MAKETEXT{"Form"}%" showimgleft="%ICONURLPATH{toggleopen}%" hideimgleft="%ICONURLPATH{toggleclose}%"}%%TMPL:END%

%TMPL:DEF{"endtopicformwisty"}%%ENDTWISTY%%TMPL:END%


%{ Start of form table }%
%TMPL:DEF{FORM:display:header}%<div class="twikiForm">%TMPL:P{"starttopicformwisty"}%
<table class='twikiFormTable' border='1'>%TMPL:P{FORM:display:header:headerrow}%%TMPL:END%


%{ Header }%
%TMPL:DEF{FORM:display:header:headerrow}%<tr><th class='twikiFormTableHRow twikiFirstCol' colspan='2'>
[[%A_TITLE%]]
</th></tr>%TMPL:END%


%{ Each row }%
%TMPL:DEF{FORM:display:row}%<tr valign='top'><td class='twikiFormTableRow twikiFirstCol' align='right'> %A_TITLE% </td><td>
%A_VALUE%
</td></tr>%TMPL:END%


%{ Footer }%
%TMPL:DEF{FORM:display:footer}%</table>%TMPL:P{FORM:display:footer:editlink}%
%TMPL:P{"endtopicformwisty"}%</div><!-- /twikiForm -->%TMPL:END%

To give the twisty toggle link the same style as the attachment twisty link, add this to pattern skin's style.css:

.twikiForm .twistyTrigger .twikiLinkLabel {
   font-size:122%; /* h4 size */
   font-weight:bold;
}

-- ArthurClemens - 17 Aug 2008

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2008-08-17 - 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.