[pmwiki-users] help with function

Hans design at flutesong.fsnet.co.uk
Thu Aug 4 03:01:00 CDT 2005


As part of my skin development of Gemini I would like to
make a section of code in skin.php into a function, so it can be
called from elsewhere, ie another function which is part of a special
markup. But I struggle with one part of the code. it works fine if its
not inside the function, and stops working if it is. Can someone help
me with this please?

Here is the code snippet I like to turn into a function.
It assigns some style elements to a #rightbar div, but only if a
RightBar page exists AND is not empty. The 'not empty' logical
comparison does not work inside the function so far.
  if ($rpage['text'] > ''
$sc is a variable holding the keyname of the color scheme.
Working code snippet:

## style rightbar box if not empty, for each color css file:
global $HTMLStylesFmt;
$grb = FmtPageName('$Group.RightBar',$pagename);
$srb = FmtPageName('$SiteGroup.RightBar',$pagename);
$rpage = ReadPage($grb);  
if (!PageExists($grb)) $rpage = ReadPage($srb); 
if ($rpage['text'] > '') {
    if ($sc == 'blue') {$HTMLStylesFmt[] = " #rightbar { .... } \n"; }
    if ($sc == 'sand') {$HTMLStylesFmt[] = " #rightbar { .... } \n"; }
    ....
    };

I wrapped it into a function like this:

function SetRightBarBackground($sc) {
global $HTMLStylesFmt;
$grb = FmtPageName('$Group.RightBar',$pagename);
$srb = FmtPageName('$SiteGroup.RightBar',$pagename);
$rpage = ReadPage($grb);  
if (!PageExists($grb)) $rpage = ReadPage($srb); 
if ($rpage['text'] > '') {
    if ($sc == 'blue') {$HTMLStylesFmt[] = " #rightbar { .... } \n"; }
    if ($sc == 'sand') {$HTMLStylesFmt[] = " #rightbar { .... } \n"; }
    ....
    };
};

but the ($rpage['text'] > '') does not work now (always 0).
$rpage does exist as an array.

-- 
Best regards,
 Hans                          





More information about the pmwiki-users mailing list