>id=divisionname<< text can be hidden/shown >><< Necessary parameters: (:showhide div=divisionname:) Optional parameters: init=hide hides the division initially (default is show) lshow=labelname label of button when div is hidden (default is Show) lhide=labelname label of button when div is shown (default is Hide) */ # Version date $RecipeInfo['ShowHide']['Version'] = '2009-02-16'; # declare $ShowHide for (:if enabled $ShowHide:) recipe installation check global $ShowHide; $ShowHide = 1; SDVA($ShowHideConfig, array( 'init' => 'show', //initially show div 'lshow' => XL("Show"), //label 'Show' 'lhide' => XL("Hide"), //label 'Hide' 'div' => '', //no default div name 'div2' => '', //no default div2 name 'printhidden' => true, // hidden divs get printed )); ## add markup (:showhide:) Markup('showhide', 'directives', '/\\(:showhide\\s*(.*?):\\)/ei', "ShowHide(\$pagename, PSS('$1'))"); ## one function to do it all, taking parameters from markup function ShowHide($pagename,$opt) { global $HTMLFooterFmt, $HTMLStylesFmt, $ShowHideConfig; # add javascript to html header $HTMLFooterFmt['showhideobj'] = " "; $opt = array_merge($ShowHideConfig, ParseArgs($opt)); # if init=hide is set initially add css code to hide div if($opt['div2']) { if($opt['init']=="hide") $HTMLStylesFmt[] = " #{$opt['div2']} {display:none}\n"; if($opt['init']=="hide" AND $opt['printhidden']==1) $HTMLStylesFmt[] = " @media print { #{$opt['div2']} {display:block} }\n" ; } if($opt['init']=="hide") $HTMLStylesFmt[] = " #{$opt['div']} {display:none}\n"; if($opt['init']=="hide" AND $opt['printhidden']==1) $HTMLStylesFmt[] = " @media print { #{$opt['div']} {display:block} }\n"; $lshow = str_replace("'","\'",$opt['lshow']); $lhide = str_replace("'","\'",$opt['lhide']); # initially place button with onclick call to javascript function return ""); }