[pmwiki-users] Testing for an empty page text variable

Randy Brown alongkiss at aprivatespot.com
Tue May 8 21:47:09 CDT 2012


I have a page text variable that spans more than one line:

     [=
     (:MyPTV:This is a 
     two line page text variable:)
     =]

Is there a way to test whether or not MyPTV is empty?

This doesn't work, because the newline breaks the markup:

     (:if !equal "{{$FullName}$:MyPTV}" "":)

I tried writing a custom markup expression to give me the length of MyPTV, but the function didn't work:

     # a custom markup expression that returns the length of the page text variable, for example: {(ptvlen "{$FullName}" "$:MyPTV")} 
     $MarkupExpr['ptvlen'] = 'PTVlen($args[0],$args[1])';
     function PTVlen ($page, $ptv) {
         $var=PageTextVar($page,'$:ptv');
         return strlen($var);	
     }

Randy


More information about the pmwiki-users mailing list