On Fri, Oct 30, 2009 at 3:45 AM, ABClf <[email protected]> wrote: > Until now, I can't make first (a) suggestion work (neither yyyy neither > yyyy-mm)
There may be some way to make it work, but I wasn't 100% sure from the start. > (c) works and is clearer than mine. > I'm also in trouble with (b) greateq and numcomp (parse error, unexpected > T_CASE ; for numcomp). I went ahead and made the necessary changes, tested it, and documented it at http://www.pmwiki.org/wiki/Cookbook/ConditionalMarkupSamples#ifnumcomp > *Does anyone know how to extract the first 4 signs from a ptv, as in : > Date : 1896, 1932, 1966 ... > (:pagelist trail=Argot.BibliographieDesDictionnaires fmt=#titredate {(substr > {=$:Date} 0 4)}=199[3-9],20[0-9][0-9] count=10:) Unfortunately you can't use markup expressions within conditionals like that. It's the order of rules. You could redefine the non-aesthetically-pleasing {pre-if-mx(...)} with the following: Markup('{pre-if-mx(', '<if', '/\\{pre-if-mx(\\(\\w+\\b.*?\\))\\}/e', "MarkupExpression(\$pagename, PSS('$1'))"); and then you get (:if ...:) capabilities, but that still doesn't work inside a pagelist. (besides, it's *really* ugly.) So at the bottom of this email you will find an altered numcomp condition which only looks at the first 4 characters. This seems very awkward to me, but maybe somebody else can come up with a more elegant solution... With this definition I was able to successfully test this pagelist: (:pagelist name=Test.N* $:abc=?* if="numcomp '{=$:abc}' <= 1993":) and (:pagelist name=Test.N* $:abc=?* if="numcomp '{=$:abc}' >= 1993":) Frankly I would probably go with the wildcard solution, but here's a working alternative if you want it... (Note that after I did numcomp I found Cookbook/ConditionalExtensions which has the various comparisons you were looking for... But obviously no substr() built in.) -Peter $Conditions['numcomp'] = 'NumericCompareArgs($condparm) == 0'; function NumericCompareArgs($arg) { $arg = ParseArgs($arg); $arg[''][0] = substr(@$arg[''][0], 0, 4); $arg[''][2] = substr(@$arg[''][2], 0, 4); #echo "args=<pre>".print_r($arg,true)."</pre><br>\n"; # Would be nice to check $arg[''][1] here using in_array() and give an error message # Would be nice to check for existence and numericalness of [0] and [2] and error nicely switch (@$arg[''][1]) { case '>': case '>': return !(@$arg[''][0] > @$arg[''][2]); break; case '>=': case '>=': return !(@$arg[''][0] >= @$arg[''][2]); break; case '<': case '<': return !(@$arg[''][0] < @$arg[''][2]); break; case '<=': case '<=': return !(@$arg[''][0] <= @$arg[''][2]); break; #case '>': case '!=': return !(@$arg[''][0] != @$arg[''][2]); break; #case '>': case '==': case '=': return !(@$arg[''][0] == @$arg[''][2]); break; default: echo "NumericCompare: ERROR: Unknown operator "....@$arg[''][1]."<br>\n"; echo "args=<pre>".print_r($arg,true)."</pre><br>\n"; return !(@$arg[''][0] == @$arg[''][2]); } } _______________________________________________ pmwiki-users mailing list [email protected] http://www.pmichaud.com/mailman/listinfo/pmwiki-users
