[pmwiki-users] Rating cookbooks

Hans design5 at softflow.co.uk
Wed Jan 28 17:35:21 CST 2009


Wednesday, January 28, 2009, 10:35:32 PM, Eemeli Aro wrote:

> I disagree with the Users: format not being summarisable; it's perhaps
> even easier with this than with one-opinion-per-line, as we can expect
> the users to be comma-delimited. Hence at least the following quick
> hack appear to work:

> in config.php:

> Markup( '^Users:', 'block', '/^Users:(.*)$/e',
>   "\"<:block,1><h2>Users</h2><p class='indent'>$1</p>\"" );
> Markup( 'count', 'directives', '/\\(:count\\s(.*?):\\)/ei',
>   "strlen('\$1')?(1+substr_count('\$1',',')):0" );

I would not use a special Users: markup to create a special output
format. I would leave it as it is to fit in with the other PTVs in
the recipe info summary section.

For counting I would suggest to use a markup expression, a sit would
proof more versatile. Something like this perhaps (basically using
your code), or we could get more fancy:

$MarkupExpr['csvcount'] = 'MxCSVCount($args[0])';
function MxCSVCount ($arg) {
        return strlen($arg) ? 1+substr_count($arg,',') : 0;
}

which can be used like {(csvcount "{$:Users}")}
or on any string, or nested with other markup expressions,
or in pagelists.


  ~Hans




More information about the pmwiki-users mailing list