[pmwiki-users] New recipe: Fox
Hans
design5 at softflow.co.uk
Wed Dec 20 16:35:36 CST 2006
Wednesday, December 20, 2006, 3:46:30 PM, Daniel wrote:
> Now one small question:
> After click on "submit" I generate a new page in a given group called "Log".
> Is there a chance to define the name of this new page dynamically with
> the current date like:
> "Log.20061220001" where 001 is a autoincrement?
Okay here is a solution: a new page variable {$NewTicket}
which is the new ticket pagename, i.e 'Log.20061220002'
Put the variable in the Fox form as
(:fox formname redirect=1 target={$NewTicket} template=... :)
...
Put this code in config.php:
# add page variable {$NewTicket}
# creates auto increasing pagename of format
# Log.20061220001 (date and 3 digit number)
$FmtPV['$NewTicket'] = 'MakeNewTicket()';
function MakeNewTicket() {
foreach(ListPages('/^Log\\.\\d/') as $i)
$issue = max(@$issue,substr($i,4));
$issueday = substr($issue,0,8);
$today = strftime("%Y%m%d", time());
if($issueday==$today) {
$nextissue = $issue+1;
$pagename = 'Log.'.$nextissue;
}
else $pagename = 'Log.'.$today.'001';
return $pagename;
}
Note that this code is group specific and deals with the exact format
you wanted. I have not tried to 'generalise' it.
Original idea adapted from PITS.php, thanks Pm!
Hans
More information about the pmwiki-users
mailing list