[pmwiki-users] How to add a variable to {$var}-markup?

Dominique Faure dominique.faure.1 at free.fr
Mon May 30 01:19:20 CDT 2005


Hi,

You could easily have what I called named properties in a previous mail 
(subject was ConditionalExtensions update and markupconsiderations) in order 
to embed meta information into
PmWiki pages:

===8<---
Markup('properties', '<if', "/\\(:properties(\\s+.*)?\\s*:\\)/e", 
"SetProperties(PSS('$1'))");

function SetProperties($args) {
 $opt = ParseArgs($args);
 foreach($opt as $n => $v) { if($n != '#') $GLOBALS['__PROPERTIES__'][$n] = 
$v; }
}

$Conditions['property'] = "ExprProperty(\$pagename, \$condparm)";

function ExprProperty($pagename, $condparm) {
  if (!preg_match("/\\s*(\\S+)\\s+(.*?)\\s*$/", $condparm, $match)) return 
'';
 return isset($GLOBALS['__PROPERTIES__'][$match[1]]) ?
  $GLOBALS['__PROPERTIES__'][$match[1]] == $match[2] : false;
}

Markup('getproperty','>setproperties', '/{\\$property\\s+(.*)\\s*}/e',
"\$GLOBALS['_PROPERTIES_']['$1']");
===8<---

You could have to set values in config.php:
 $GLOBALS['__PROPERTIES__']['meta-group'] = 'LyX';

and in your pages:
 (:properties meta-group=LyX:)

then get a value in your pages:
 (:property meta-group:)

and to test values:
(:if property meta-group LyX:)
...
(:ifend:)

Regards,
Dominique

At Sunday, May 29, 2005 8:23 PM [GMT+1=CET], chr at home.se wrote:

> Hi
>
> How do I go about making a new variable available as markup such as for
> instance
>
> {$metagroup}
>
> where I'd assing $metagroup in my config.php of course.
>
> regards
> /Christian
>
> PS. I know I could do this using Markup(), but I'm guessing there's an
> even easier way?? 




More information about the pmwiki-users mailing list