SerialPageNames

Summary: Markup expressions to create serial page names
Version: 2008-05-25
Prerequisites: PmWiki 2.2.0
Status: stable
Maintainer: HansB
Categories: Markup Forms Fox PHP55 PHP72

Questions answered by this recipe

How can I create numerical page names which increase automatically for every new page?
How can I create serial page names?
How can I create daily ticket page names, combining a date part with a serial numerical part?

Description

The script includes markup expressions to help with creating serial page names. Now part of PowerTools! Download powertools.phpΔ, copy to your cookbook folder, and install in your local config.php by including:

include_once("$FarmD/cookbook/powertools.php");

This provides you with a number of new markup expressions, which you can use in your pages, and especially in your forms for producing new serial pages.

  • {(serialname Group Name)} - Creates a new serial pagename of format Group.Name0001 (appended 4-digit number defined by variable $SerialStart), incrementing the ending number part of pages like Group.Name1234. So if you got a page Group.Name0010 the markup expression will return Group.Name0011. If Name is omitted it will create a purely numeric page name. If Group is omitted it will act in the current group.
  • {(serial Group Name)} - As above, but returns only the new numeric part: So for a page Group.Name0010 it returns 0011. $SerialStart is set as default to 0001 and can be changed in config.php.
  • {(newticket Group)} - Creates a new serial page name of format Group.20071113001 (date and 3 digit number). With new pages being added the 3-digit serial number will increase on the day, but on the next day the date part increases and the serial 3-digit part starts at 001 again. If group is omitted it will look in the current group.

Example using a form processed with Fox

The following form will display just a button. When clicked the form will create a new serial page in group ToDo using the Name part prefix of Jack-, basing the new page on a template page Site.ToDoTemplate. The user will be redirected to the new page.

(:messages:)
(:fox newtodo template=Site.ToDoTemplate redirect=1:)
(:input hidden target '{$$(serialname ToDo Jack- )}':)
(:input submit post "Create New ToDo Page":)
(:foxend newtodo:)

Note that the serialname expression is enclosed in hyphens, and that it is used here as a replacement variable {$$(serialname ...)} and not as a normal markup expression {(serialname ....)}. Normally markup expressions will be evaluated when the page is loaded, whereas the expression written as a replacement variable will only be evaluated when the form is processed, thereby overcoming possible conflicts of page names if another user is creating a page at about the same time.

Notes

Release Notes

  • 2008-05-25: Fixed $SerialStart
  • 2007-11-13: initial release

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Comments

$SerialStart doesn't seem to have any effect. Setting $ThreadStart to $SerialStart in the code fixed the problem. Is this a bug or did I miss something? JHJ, 2008-05-25

It was indeed a bug. Now fixed. Thanmks for pointing this out! - HansB May 25, 2008, at 02:27 AM

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.