[pmwiki-users] Fwd: pagelist templates strange behaviour

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 27 12:57:18 CDT 2007


On Tue, Mar 27, 2007 at 07:26:37PM +0200, Jean-Fabrice [gmail] wrote:
> Patrick,
> 
> maybe it's a bug, maybe it's me, but I have some difficulties using
> custom defined variable in pagelist fmt. Here is my previous message,
> in case you missed it.

The code is a little complex, which is why I haven't been able to
study it closely.  But let me offer a couple of simplifications as
a starting point...

> I then defined the following variables :
> $FmtPV['$MonthLink'] = 'substr(FmtPageName(\'$Name\',$pagename),0,6)';
> $FmtPV['$MonthLinkText'] = 'strftime("%B %Y",
> mktime(12,0,0,substr(FmtPageName(\'$Name\',$pagename),4,2),15,substr(FmtPageName(\'$Name\',$pagename),0,4)))';
> $FmtPV['$DayLinkText'] = 'strftime("%A %d %B %Y",
> mktime(12,0,0,substr(FmtPageName(\'$Name\',$pagename),4,2),substr(FmtPageName(\'$Name\',$pagename),6,2),substr(FmtPageName(\'$Name\',$pagename),0,4)))';

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)))';


> This used to work fine but it doesn't anymore. 
> ...
>
> [[#dailytrail]]
> (:if equal {*$FullName} {=$FullName}:)[[{<$FullName}|<<
> {<$DayLinkText}]]&nbsp;&nbsp;|&nbsp;&nbsp;[[{$MonthLink}|{$MonthLinkText}]]&nbsp;&nbsp;|&nbsp;&nbsp;[[{>$FullName}|{>$DayLinkText}>>]](:if:)
> [[#dailytrailend]]

Note that {$MonthLink} and {$MonthLinkText} will refer to the page in
which they are written -- in this case, the page containing your template.
You probably want {=$MonthLink} or {*$MonthLink} to get things to
use the name of the page being displayed.

I'm also planning to add some date/time formatting routines for pagenames
directly into the core, which would simplify the above even further.

Pm



More information about the pmwiki-users mailing list