While PmWiki becomes more and more powerful and flexible, it can be used to
be the site engine of many different kinds of web sites like blogs or forums.
But in those cases a permanent page creator name is very impotent. In the
other hand, in the wiki logic, creater is less impotent than the modifier.
In fact PmWiki only supply {$LastModifiedBy} and no {$Creater} at all.
I'm not asking a {$Creater} variable, but if PM can take it into
consideration that would be great. I'm looking for a way to use available
methods to do the same work. My question is:
If I use Hans's NewPageBoxPlus which can use another page as template, and if
I put a PTV like (:creator: ... :) in the template, how can I 'save' the
value of the $Author right into the PTV at the same time when a page was
saved?
Wish my poor English is good enough to be understood.
Cheers,
imoc
_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users
I find Hans's code here:
http://groups.google.com/group/pmwiki-users/
browse_thread/thread/cd5856c9e1c0b3f0/ea594cc45bd54738?
lnk=gst&q=creator#ea594cc45bd54738
Which sulved my problem. Thanks Hans.
Hi Hans, I add these code in 'config.php' and put {$Creator} variable in
'Site.PageAction' like 'Post by {*$Creator}'. It worked in every page
except new page. While creating new page, there is a warning:
Warning: end() [function.end]: Passed variable is not an array or
object in /home/jbooknet/public_html/tw/local/config.php on line 121
In my config.php the line 121 is:
return end($authors);
If I ignore the message. The page can be saved with no problem. and
everything are ok at next edit.
>> $FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
>> function PageCreationAuthor($pagename) {
>> $page = RetrieveAuthPage($pagename, 'read', true);
>> foreach($page as $key => $value)
>> if (strstr($key,'author'))
>> $authors[$key] = $value;
>> return end($authors);
>> }
>>
> Hi Hans, I add these code in 'config.php' and put {$Creator} variable in
> 'Site.PageAction' like 'Post by {*$Creator}'. It worked in every page
> except new page. While creating new page, there is a warning:
> Warning: end() [function.end]: Passed variable is not an array or
> object in /home/jbooknet/public_html/tw/local/config.php on line 121
> In my config.php the line 121 is:
> return end($authors);
For a new page there is no author set in the page attributes.
Try this:
$FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
function PageCreationAuthor($pagename) {
$page = RetrieveAuthPage($pagename, 'read', true);
foreach($page as $key => $value)
if (strstr($key,'author'))
$authors[$key] = $value;
if (is_array($authors))
return end($authors);
else return '';
}
or perhaps the last line could also be
else return '{$Author}';
~Hans
$FmtPV['$Creator'] = 'PageCreationAuthor($pagename)';
function PageCreationAuthor($pagename) {
$page = RetrieveAuthPage($pagename, 'read', true);
foreach($page as $key => $value)
if (strstr($key,'author'))
$authors[$key] = $value;
if (is_array($authors))
return end($authors);
else return '';
}
or perhaps the last line could also be
else return '{$Author}';
~Hans
Thanks Hans,
As usual, it worked again. :)
> As usual, it worked again. :)
Well, not quite :-(
The functions pulls the last author name from the page's diff history.
This is usually the first auther = page creator.
But if you delete part of the history with ExpireDiff or by setting
$DiffKeepDays to a short time period, the last author in th ehistory
changes, and so does the $Creator page variable.
Thank you Anke for pointing this out!
What we really need is a Creator page attribute, written into the page
when the page is created, and set to the author, alongside the
existing one for creation time 'ctime'.
I suggest 'cauthor'.
It needs a change of code in pmwiki.php in function ReadPage:
add $Author to the global list of that function, and
change line
if (@!$page) $page['ctime'] = $Now;
to
if (@!$page) { $page['ctime'] = $Now; $page['cauthor'] = $Author; }
Maybe Pm can be persuaded to do this core change.
Then we can have a true {$Creator} or {$PageCreatedBy} page variable.
~Hans
Well, not quite :-(
The functions pulls the last author name from the page's diff history.
This is usually the first auther = page creator.
But if you delete part of the history with ExpireDiff or by setting
$DiffKeepDays to a short time period, the last author in th ehistory
changes, and so does the $Creator page variable.
Thank you Anke for pointing this out!
What we really need is a Creator page attribute, written into the page
when the page is created, and set to the author, alongside the
existing one for creation time 'ctime'.
I suggest 'cauthor'.
It needs a change of code in pmwiki.php in function ReadPage:
add $Author to the global list of that function, and
change line
if (@!$page) $page['ctime'] = $Now;
to
if (@!$page) { $page['ctime'] = $Now; $page['cauthor'] = $Author; }
Maybe Pm can be persuaded to do this core change.
Then we can have a true {$Creator} or {$PageCreatedBy} page variable.
~Hans
---------------------------------------------
Thanks for thinking this seriously, Hans.
Since Hans was baned by gmane( his post can not show here in gmane.org)
So I think I've to invite Pm to advise us what he think about this
issue. I write some word in title. Wish Pm could see it.
Cheers,