|
GBU Strasbourg
|
<--> |
| October 25, 2025, at 12:14 AM | PmWiki / MarkupVariables |
MarkupVariablesauthors (intermediate) This page describes the "variables" that are available in the markup through the construction Note: These variables do not necessarily exist in the PHP code, i.e. you cannot assume that using Here are the variables that are available through markup: {$Group} - page's group name, as in "PmWiki"
{$Groupspaced} - spaced group name, as in "Pm Wiki"
{$DefaultGroup} - default group name, as in "Main"
{$Name} - page name, as in "MarkupVariables"
{$Namespaced} - spaced page name, as in "Markup Variables"
{$DefaultName} - name of default page, as in "HomePage"
{$FullName} - page's full name, as in "PmWiki.MarkupVariables"
{$Title} - page title (may differ from Name), as in "MarkupVariables"
{$Titlespaced} - title/spaced page name, as in "Markup Variables"
{$UrlPage} - requested URL (valid only on the PageNotFound page)
{$LastModified} - date page was edited, as in "September 01, 2005, at 05:18 AM"
{$LastModifiedBy} - page's last editor, as in "Pm"
{$LastModifiedHost} - IP of page's last editor, as in "24.1.26.255"
{$Author} - the name of the person currently interacting with the site, as in ""
{$AuthId} - current authenticated id, as in ""
{$Version} - PmWiki version, as in "pmwiki-2.0.13"
administrators (intermediate) Defining additional markup variablesYou can define additional markup variables by adding something like the
following to your configuration script (e.g.
Markup('{$local-variables}', '>{$fmt}',
'/{\\$(Var1|Var2|Var3)}/e',
"\$GLOBALS['$1']");
$GLOBALS['Var1'] = "Variable 1";
$GLOBALS['Var2'] = "Variable 2";
$GLOBALS['Var3'] = "Variable 3";
This method of adding the markup variables will also make them known to the
function Markup('{$Var1}', '>{$fmt}', '/\\{\\$Var1\\}/', 'Variable 1');
Markup('{$Var2}', '>{$fmt}', '/\\{\\$Var2\\}/', 'Variable 2');
Markup('{$Var3}', '>{$fmt}', '/\\{\\$Var3\\}/', 'Variable 3');
Example 1Let's say you want
Markup('{$local-variables}', '>{$fmt}',
'/{\\$(Var1|Var2|mygroup)}/e',
"\$GLOBALS['$1']");
$GLOBALS['Var1'] = "Variable 1";
$GLOBALS['Var2'] = "Variable 2";
$GLOBALS['mygroup'] = lower(FmtPageName('$Group', $pagename));
Using the second approach, you need to add something like this to your configuration script:
Markup('{$mygroup}', '>{$fmt}',
'/\\{\\$mygroup\\}/',
lower(FmtPageName('$Group', $pagename)));
Markup('{$Var1}', '>{$fmt}', '/\\{\\$Var1\\}/', 'Variable 1');
Markup('{$Var2}', '>{$fmt}', '/\\{\\$Var2\\}/', 'Variable 2');
Example 2Here is an example of a situation where you can't really define a variable
as described earlier. Let's say you want each instance of
Markup('{$tic-toc}', '>{$var}',
'/\\{\\$tic-toc\\}/e',
"array_sum(explode(' ',microtime()))");
LinksAlso see these pages:
<< Conditional markup | DocumentationIndex | Markup master index >> |
| Validate the XHTML and CSS of this page. | Page last modified on September 01, 2005, at 05:18 AM | Edit History Print Recent Changes |
|
Powered by PmWiki |
||