Apolyton CTP2 section
Apolyton CTP2 files
Apolyton CTP2 forums
Source Code Project SVN
||Search the Wiki:|
PagesRecent Changes Search
Create a new page:
AE Modding Wiki : PmWiki : FmtPageName
This page describes an internal function in PmWiki's engine called FmtPageName(). The contents are not intended for those with a weak heart ;-)
Also see: PmWiki.Functions
The substitutions go as follows:
According to PM, as a general rule it's unwise to be calling FmtPageName() on strings that are coming from page markup, as this exposes the ability for people to view the values of variables that perhaps they shouldn't see. This is also why page variables (which come from markup) use PageVar?() and PageTextVar?() and don't go through FmtPageName().
Availability of Variables in FmtPageName
To be very specific, here's what Pm wrote regarding different ways of defining a variable that can be used by FmtPageName (when it is formatting a string):
Also see: Cookbook:Functions#FmtPageName
Finally, here's something else Pm wrote that is related and explains why we have this function:
In order to produce its output, PmWiki has to do a variety of string substitutions:
PmWiki centralizes all of that substitute-a-dynamic-value-in-a-string into the FmtPageName() subroutine. Because some things are extremely dynamic, such as the url or group for an arbitrary page that is not the current one, those things cannot be simple global PHP variables. Or, if they do become global variables, they're variables that cannot be trusted to hold a value for very long because some other routine (that may happen to be formatting a string for a different page) will come along and change that global variable for whatever it happens to be doing.
A limited set of $-substitutions -- basically anything that corresponds to a page attribute -- are not PHP variables and are only available through the FmtPageName() subroutine. The complete set of these special substitutions is $Group, $Name, $FullName, $PageUrl, $Title, $Titlespaced, $Namespaced, $Groupspaced, $LastModifiedBy, $LastModifiedHost, and $LastModified. These items cannot just be standard PHP variables because often PmWiki needs to obtain the url, name, group, title, etc. of a page other than the one currently being viewed by a browser.
At the moment, $Title, $LastModified, $LastModifiedBy, and $LastModifiedHost can only work if the page's attributes have been loaded and cached using the PCache function. So, to get at these values one must typically do:
$page = ReadPage($pagename); PCache($pagename, $page); $ptitle = FmtPageName('$Title', $pagename); $pauthor = FmtPageName('$LastModifiedBy', $pagename);
Page last modified on September 10, 2011, at 06:08 PM
|AE Modding Wiki built with PmWiki Design: BureauBert|