[pmwiki-users] Fwd: pagelist templates strange behaviour

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 27 17:15:48 CDT 2007


On Tue, Mar 27, 2007 at 10:21:04PM +0200, Jean-Fabrice [gmail] wrote:
> 2007/3/27, Patrick R. Michaud <pmichaud at pobox.com>:
> 
> >Inside of a page variable one can get the name and group by just using 
> >$name
> >and $group, so a much simpler implementation of the above would be:
> >
> >  $FmtPV['$MonthLink'] = 'substr($name,0,6)';
> >  $FmtPV['$MonthLinkText'] =
> >    'strftime("%B %Y", 
> >    mktime(12,0,0,substr($name,4,2),15,substr($name,0,4)))';
> >  $FmtPV['$DayLinkText'] =
> >    'strftime("%A %d %B 
> >    %Y",mktime(12,0,0,substr($name,4,2),substr($name,6,2),substr($name,0,4)))';
> Well, I used to use $name but using FmtPageName appeared to me a more
> 'legal' way. Anyway. I think I have a problem with my configuration
> because at the stage of my FmtPV definition, $name appears to be
> empty.

$name isn't used at the point of definition -- it's used when the page
variable is actually evaluated (i.e., much later in the program).
Note the single quotes around the entire string, which puts a literal
'$name' into the string.  The string is then evaluated later, when
we know the name of the page for which the variable applies.

Consider something like {Group.Page$Var} -- in this case we can't
know the value of '$name' at the time $FmtPV['$Var'] is defined,
because the pagename to be used comes from the markup.   So, when
we need to evaluate a page variable, the PageVar() sets a value for
$name and then executes the code given by $FmtPV['$Var'].

> What I still don't understand with my original code is why
> {<$FullName} render correctly while {$<DayLinktext} gives today and
> $<DayLinkText render a strange_formated_but_good result (yesterday)

Should that be {<$DayLinktext}?  Or is the transposition intentional 
here?

Pm



More information about the pmwiki-users mailing list