[pmwiki-users] Problem with PTV in Pagelists
Ian Barton
lists at manor-farm.org
Fri May 28 08:32:42 CDT 2010
On 28/05/10 12:56, Eemeli Aro wrote:
> On 28 May 2010 14:37, Ian Barton<lists at manor-farm.org> wrote:
>> The pagelist displays the next five events in the Calendar group. The
>> problem is with $JournalDateTitle. This splits the filename from
>> Calendar.201005028 into a more human readable format. It displays
correctly
>> when I use it on a page in the calendar group, but not displayed in
a side
>> bar on the front page. This worked OK with the previous version of
PmWiki
>> that I had installed.
>
> Where's $JournalDateTitle coming from? Is it some custom code that's
> generating it, as it doesn't appear on the page sources?
>
> I'd recommend instead using the standard MarkupExpression ftime:
>
> {(ftime fmt="%A, %B %d, %Y" when='{=$Name}')}
>
> instead of {=$JournalDateTitle}.
It's a custom function (see end of message). It's designed to return a
human readable date from the Page name e.g. News.20100527 would give
Thursday, 27 May 2010.
If you look at http://www.dodcott-cum-wilkesley.co.uk/wiki/News/20100527
you can see that it works in the base page, but not when used in a pagelist.
I don't normally write php and it's been a couple of years since I set
up this site. As it's always worked OK before the latest upgrade, my
memory of why I did it that way is a bit rusty:)
{(ftime fmt="%A, %B %d, %Y" when='{=$Name}')} doesn't appear to work,
see the page referenced above for the output.
Thanks for your help.
# Title that appears as at the top of each entry.
$FmtPV['$JournalDateTitle'] = 'TitleToDate2($pagename)'
function TitleToDate2($pagename) {
$tname =
preg_replace("/[^.]*\.([\d\-]*)(.*)/e","'$1'==''?'$2':'$1'",$pagename);
preg_match("/([\d]*)[-]?([\d]*)[-]?([\d]*)/e",$tname,$m);
$year = (integer) substr($tname, 0, 4);
$month = (integer) substr($tname, 4, 2);
$day = (integer) substr($tname, 6, 2);
$tdate= mktime(0, 0, 0, $month, $day, $year);
$bmonth = strftime("%A, %d %B %Y",$tdate);
return $bmonth;
}
More information about the pmwiki-users
mailing list