Other Variables
- %apply=item id=Fmt V%
$FmtV
- This variable is an array that is used for string substitutions at the end of a call to
FmtPageName()
. For each element in the array, the "key" (interpreted as a string) will be replaced by the corresponding "value". The variable is intended to be a place to store substitution variables that have frequently changing values (thus avoiding a rebuild of the variable cache makingFmtPageName()
faster). Also see$FmtP
. - Values of
$FmtV
are set by the internal functionsFormat Table Row
,Link I Map
,Handle Browse
, Preview Page,Handle Edit
,Pm Wiki Auth
, andPasswd Var
, apparently to set values for system generated string substitutions likePage Text
. - %apply=item id=Fmt P%
$FmtP
- This variable is an array that is used for pattern substitutions near the beginning of a call to
FmtPageName()
. For each element in the array, the "key" (interpreted as a pattern) will be replaced by the corresponding value evaluated for the name of the current page. This is for instance used to handle⚠ $-substitutions that depend on the pagename passed to <code class='escaped'>FmtPageName()</code>. Also see $
Fmt V. - From
robots.php
: If⚠ $EnableRobotCloakActions is set, then a pattern is added to $
Fmt P to hide any "?action=" url parameters in page urls generated by Pm Wiki for actions that robots aren't allowed to access. This can greatly reduce the load on the server by not providing the robot with links to pages that it will be forbidden to index anyway. - %apply=item id=Fmt PV%
$FmtPV
- This variable is an array that is used for defining Page Variables. New variables can be defined with
$FmtPV['$VarName'] = 'variable definition';
which can be used in markup with{$VarName}
. Please note that the contents of$FmtPV['$VarName']
areeval()
ed to produce the final text for$VarName
, so the contents must be a PHP expression which is valid at the time of substitution. In particular, this does not work:#This doesn't work
⚠ $FmtPV['$
My Text'] = "This is my text."; # WARNING: Doesn't work!
- The problem is that the text
This is my text.
is not a valid PHP expression. To work it would need to be placed in quotes, so that what actually gets stored in$FmtPV['$MyText']
is"This is my text."
which is a valid PHP expression for a text string. Thus the correct way to do this would be with an extra set of quotes:#This will work
⚠ $FmtPV['$
My Text'] = '"This is my text."';
- This also has implications for how internal PHP or Pm Wiki variables are accessed. To have the page variable
$MyVar
produce the contents of the internal variable$myvar
, many folks try the following which does not work:#This doesn't work either!
$myvar = Some Complex Function();
⚠ $FmtPV['$
My Var'] = $myvar; # WARNING: Doesn't work!
- There are several correct ways to do this, depending on whether you need the value of the
$myvar
variable as it was at the time the$FmtPV
entry was created, or at the time that a particular instance of$MyVar
is being rendered on a page. For most simple page variables that don't change during the processing of a page its more efficient to set the value when the entry is created:$myvar = Some Complex Function();
⚠ $FmtPV['$
My Var'] = "'" .⚠ $myvar . "'"; #capture contents of $
myvar
- NOTE: If
$myvar
should contain single quotes, the above won't work as is, and you'll need to process the variable to escape any internal quotes. - For more complex cases where an internal variable may have different values at different places in the page (possibly due to the effects of other markup), then you need to make the
$FmtPV
entry make an explicit reference to the global value of the variable (and the variable had better be global) like this:global $myvar;
⚠ $FmtPV['$
My Var'] = '$GLOBALS["myvar"]';
- Finally, there's nothing to stop you from simply having the evaluation of the
$FmtPV
entry execute a function to determine the replacement text:# add page variable {$Today}, formats today's date as yyyy-mm-dd
⚠ $FmtPV['$
Today'] = 'PSFT("%Y-%m-%d", time() )';
- Once again, please note that the values of the elements of
$FmtPV
areeval()
ed so always sanitize any user input. The following is very insecure:-
⚠ $FmtPV['$
Var'] = $_REQUEST['Var'];# critically insecure, allows PHP code injection
-
⚠ $FmtPV['$
Var'] = '"'. addslashes($_REQUEST['Var']).'"';# critically insecure, allows PHP code injection
- See the recipe Cookbook:HttpVariables for a better way to use these variables.
- See Cookbook:MoreCustomPageVariables for more examples of how to use
$FmtPV
. - %apply=item id=Max Page Text Vars%
$MaxPageTextVars
- This variable prevents endless loops in accidental recursive PageTextVariables which could lock down a server. Default is 500 which means that each Page Text Variable from one page can be displayed up to 500 times in one wiki page. If you need to display it more than 500 times, set in
config.php
something like
# ten thousand times$MaxPageTextVars
= 10000; - %apply=item id=Default Unset Page Text Vars%
$DefaultUnsetPageTextVars
- An array setting default values to page text variables which are not defined in the page, or when the user doesn't have read permissions for the page. See PageTextVariables#default.
- %apply=item id=Default Empty Page Text Vars%
$DefaultEmptyPageTextVars
- An array setting default values to page text variables which are defined in the page but empty. See PageTextVariables#default.
:⚠ $PageCacheDir: Enables the cache of most of the HTML for pages with no conditionals. The variable contains the name of a writable directory where PmWiki can cache the HTML output to speed up subsequent displays of the same page. Default is empty, which disables the cache. See also $
Page List Cache Dir.
# Enable HTML caching in work.d/.pagecache $PageCacheDir = 'work.d/.pagecache';
- %apply=item id=Markup Markup Level%
$MarkupMarkupLevel
- This global variable is a positive integer when the markup processing engine is inside a
(:markup:)
block; it is 0 (zero) or null otherwise. - %apply=item id=Enable Input Data Attr%
$EnableInputDataAttr
- This variable controls whether input form elements should accept custom
data-*
attributes. By default they do.# Disable data-* attributes in forms $EnableInputDataAttr = 0;
- %apply=item id=Markup Directive Functions%
$MarkupDirectiveFunctions
- This is an array that allows recipe authors to easily configure custom directives. See Cookbook:MarkupDirectiveFunctions.
This page may have a more recent version on pmwiki.org: PmWiki:OtherVariables, and a talk page: PmWiki:OtherVariables-Talk.