>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) */ define(SHOWHIDE_VERSION, '2006-08-19'); # declare $ShowHide to be able to check if showhide global $ShowHide; $ShowHide = 1; ## add markup (:showhide:) Markup('showhide', 'directives', '/\\(:showhide\\s*(.*?):\\)/i', "muShowHide"); function muShowHide($m) { extract($GLOBALS["MarkupToHTML"]); return ShowHide($pagename,$m[1]); } ## one function to do it all, taking parameters from markup function ShowHide($pagename,$opt) { global $HTMLHeaderFmt, $HTMLStylesFmt; $defaults = array( 'div' => '', 'init' => 'show', 'lshow' => FmtPageName('$[Show]', $pagename), 'lhide' => FmtPageName('$[Hide]', $pagename), 'div2' => '', ); $opt = array_merge($defaults, ParseArgs($opt)); # add javascript to html header $HTMLHeaderFmt['showhideobj'] = " "; # if init=hide is set initially add css code to hide div if($opt['div2']) $opt['init']=="hide" ? "" : $HTMLStylesFmt[] = " #{$opt['div2']} {display:none} \n" ; $opt['init']=="hide" ? $HTMLStylesFmt[] = " #{$opt['div']} {display:none} \n" : ""; # initially place button with onclick call to javascript function return ""); } #end of ShowHide function