version=pmwiki-2.2.2 ordered=1 urlencoded=1 agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081216 Ubuntu/8.04 (hardy) Firefox/2.0.0.19 author=Petko charset=ISO-8859-1 csum=$MaxPageTextVars host=81.65.14.164 name=PmWiki.OtherVariables rev=69 targets=PmWiki.FmtPageName,PmWiki.PageVariables,PmWiki.PageTextVariables text=(:Summary:Variables not yet classified:)%0a[[#FmtV]]%0a:$FmtV: %0a: :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 making @@[[FmtPageName]]()@@ faster). Also see $FmtP. %25green%25''Values of $FmtV are set by the internal functions FormatTableRow, LinkIMap, HandleBrowse, PreviewPage, HandleEdit, PmWikiAuth, and PasswdVar, apparently to set values for system generated string substitutions like PageText.''%25%25%0a%0a[[#FmtP]]%0a:$FmtP:%0a: :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 [@FmtPageName()@]. Also see $FmtV. %25green%25From robots.php: ''If $EnableRobotCloakActions is set, then a pattern is added to $FmtP to hide any "?action=" url parameters in page urls generated by PmWiki 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.''%0a%0a%0a[[#FmtPV]]%0a:$FmtPV:%0a: :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']@] are [@eval()@]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, %25red%25this does not work:%25%25%0a%0a:: :%25red%25[@#This doesn't work@]%25%25%0a:: :[@$FmtPV['$MyText'] = "This is my text."; # WARNING: Doesn't work!@]%0a%0a: :The problem is that the text %25blue%25[@This is my text.@]%25%25 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 %25blue%25[@"This is my text."@]%25%25 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:%0a%0a:: :[@#This will work@]%0a:: :[@$FmtPV['$MyText'] = '"This is my text."';@]%0a%0a: :This also has implications for how internal PHP or PmWiki variables are accessed. To have the page variable [@$MyVar@] produce the contents of the internal variable [@$myvar@], many folks try the following %25red%25which does not work:%25%25%0a%0a:: :%25red%25[@#This doesn't work either!@]%0a:: :[@$myvar = SomeComplexFunction();@]%0a:: :[@$FmtPV['$MyVar'] = $myvar; # WARNING: Doesn't work!@]%0a%0a: :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:%0a%0a:: :[@$myvar = SomeComplexFunction();@]%0a:: :[@$FmtPV['$MyVar'] = "'" . $myvar . "'"; #capture contents of $myvar@]%0a%0a: :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.%0a%0a: :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:%0a%0a:: :[@global $myvar;@]%0a:: :[@$FmtPV['$MyVar'] = '$GLOBALS["myvar"]';@]%0a%0a: :Finally, there's nothing to stop you from simply having the evaluation of the [@$FmtPV@] entry execute a function to determine the replacement text:%0a%0a:: :[@# add page variable {$Today}, formats today's date as yyyy-mm-dd@]%0a:: :[@$FmtPV['$Today'] = 'strftime("%25Y-%25m-%25d", time() )';@]%0a%0a: :See [[Cookbook:MoreCustomPageVariables]] for more examples of how to use [@$FmtPV@].%0a%0a:$MaxPageTextVars: This variable prevents endless loops in accidental recursive [[PageTextVariables]] which could lock down a server. Default is 500 which means that each PageTextVariable from one page can be displayed up to 500 times in one wiki page.%0a time=1246800413