version=pmwiki-2.2.0-beta68 ordered=1 urlencoded=1 agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 author=simon charset=ISO-8859-1 csum=not on trail (deprecated) host=202.37.32.2 name=PmWiki.MarkupVariables rev=24 targets=PmWiki.PageVariables,PmWiki.Variables,PmWiki.PmWiki,PmWiki.Functions,PmWiki.MarkupMasterIndex text=(:Summary:redirects to [[PmWiki/Page variables]]:)%0a(:redirect PmWiki/PageVariables:)%0a->%25note%25 Note: This page is obsolete -- see [[Page Variables]] instead.%0a%0a[[#desc]]This page describes the "variables" that are available in the markup through the construction @@{$''%3cvariable>''}@@. For example, putting "[@{$Group}@]" in the markup of this page renders as "{$Group}".%0a%0aNote: These variables do not necessarily exist in the PHP code, i.e. you cannot assume that using [@$group@] in [@local/config.php@] will produce the correct result. Instead, check the [[Variables#index| list of internal Variables]] first, you may find a match.%0a%0aHere are the variables that are available through markup:%0a%0a->[@{$Group}@] - page's group name, as in "`{$Group}"%0a->[@{$Groupspaced}@] - spaced group name, as in "{$Groupspaced}"%0a->[@{$DefaultGroup}@] - default group name, as in "{$DefaultGroup}"%0a->[@{$SiteGroup}@] - default group name for e.g. RecentChanges, as in "{$SiteGroup}"%0a->[@{$Name}@] - page name, as in "`{$Name}"%0a->[@{$Namespaced}@] - spaced page name, as in "{$Namespaced}"%0a->[@{$DefaultName}@] - name of default page, as in "`{$DefaultName}"%0a->[@{$FullName}@] - page's full name, as in "`{$FullName}"%0a->[@{$Title}@] - page title (may differ from Name), as in "{$Title}"%0a->[@{$Titlespaced}@] - title/spaced page name, as in "{$Titlespaced}"%0a->[@{$UrlPage}@] - requested URL (valid only on the `PageNotFound page)%0a%0a->[@{$LastModified}@] - date page was edited, as in "{$LastModified}"%0a->[@{$LastModifiedBy}@] - page's last editor, as in "{$LastModifiedBy}"%0a->[@{$LastModifiedHost}@] - IP of page's last editor, as in "{$LastModifiedHost}"%0a%0a->[@{$Author}@] - the name of the person currently interacting with the site, as in "{$Author}"%0a->[@{$AuthId}@] - current authenticated id, as in "{$AuthId}"%0a%0a->[@{$Version}@] - [[PmWiki]] version, as in "{$Version}"%0a%0a%25audience%25 administrators (intermediate)%0a!! Defining additional markup variables%0a%0aYou can define additional markup variables by adding something like the%0afollowing to your configuration script (e.g. @@local/config.php@@):%0a [=%0a Markup('{$local-variables}', '>{$fmt}',%0a '/{\\$(Var1|Var2|Var3)}/e',%0a "\$GLOBALS['$1']");%0a $GLOBALS['Var1'] = "Variable 1";%0a $GLOBALS['Var2'] = "Variable 2";%0a $GLOBALS['Var3'] = "Variable 3";%0a=]%0a%0aThis method of adding the markup variables will also make them known to the%0afunction @@[[FmtPageName -> PmWiki.Functions#FmtPageName]]@@ which may or%0amay not be desirable. If you don't want that, then define the extra markup%0avariables directly, like this:%0a%0a Markup('{$Var1}', '>{$fmt}', '/\\{\\$Var1\\}/', 'Variable 1');%0a Markup('{$Var2}', '>{$fmt}', '/\\{\\$Var2\\}/', 'Variable 2');%0a Markup('{$Var3}', '>{$fmt}', '/\\{\\$Var3\\}/', 'Variable 3');%0a%0a%0a!!![[#ex1]] Example 1%0a%0aLet's say you want [@{$mygroup}@] to render as the name of the current group%0ausing only lower case letters. Here's how you could do it using the first%0aapproach described above:%0a%0a [=%0a Markup('{$local-variables}', '>{$fmt}',%0a '/{\\$(Var1|Var2|mygroup)}/e',%0a "\$GLOBALS['$1']");%0a $GLOBALS['Var1'] = "Variable 1";%0a $GLOBALS['Var2'] = "Variable 2";%0a $GLOBALS['mygroup'] = lower(FmtPageName('$Group', $pagename));%0a=]%0a%0aUsing the second approach, you need to add something like this to your%0aconfiguration script:%0a%0a [=%0a Markup('{$mygroup}', '>{$fmt}',%0a '/\\{\\$mygroup\\}/', %0a lower(FmtPageName('$Group', $pagename)));%0a%0a Markup('{$Var1}', '>{$fmt}', '/\\{\\$Var1\\}/', 'Variable 1');%0a%0a Markup('{$Var2}', '>{$fmt}', '/\\{\\$Var2\\}/', 'Variable 2');%0a=]%0a%0a!!![[#ex2]] Example 2%0a%0aHere is an example of a situation where you can't really define a variable%0aas described earlier. Let's say you want each instance of [@{$tic-toc}@] to%0abe replaced with the current time in system ticks when that part of the page%0ais output. The difference here is that a function needs to be invoked (to%0aget the current time) for each of the occurences. In order to do this, just%0ause the function [@Markup()@] as usual. Here's how it could be done:%0a [=%0a Markup('{$tic-toc}', '>{$var}',%0a '/\\{\\$tic-toc\\}/e',%0a "array_sum(explode(' ',microtime()))");%0a=]%0a%0a%0a!! Links%0a%0aAlso see these pages:%0a%0a* [[PmWiki.Variables]] — about variables internal to PmWiki.%0a* [[PmWiki.MarkupMasterIndex]] — complete list of PmWiki markups.%0a%0a time=1220218300