authors (intermediate)

This page describes the "variables" that are available in the markup through the construction {$<variable>}. For example, putting "{$Group}" in the markup of this page renders as "PmWiki".

Note: 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 list of internal Variables first, you may find a match.

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"
{$SiteGroup} - default group name for e.g. RecentChanges, as in "Site"
{$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 "01 september 2005 05:18"
{$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.3.15"

administrators (intermediate)

Defining additional markup variables

You can define additional markup variables by adding something like the
following to your configuration script (e.g. local/config.php):

 
	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 FmtPageName which may or
may not be desirable. If you don't want that, then define the extra markup
variables directly, like this:

	Markup('', '>', '/\\{\\$Var1\\}/', 'Variable 1');
	Markup('', '>', '/\\{\\$Var2\\}/', 'Variable 2');
	Markup('', '>', '/\\{\\$Var3\\}/', 'Variable 3');

Example 1

Let's say you want {$mygroup} to render as the name of the current group
using only lower case letters. Here's how you could do it using the first
approach described above:

 
	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 2

Here 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 {$tic-toc} to
be replaced with the current time in system ticks when that part of the page
is output. The difference here is that a function needs to be invoked (to
get the current time) for each of the occurences. In order to do this, just
use the function Markup() as usual. Here's how it could be done:

 
	Markup('{$tic-toc}', '>{$var}',
	       '/\\{\\$tic-toc\\}/e',
	       "array_sum(explode(' ',microtime()))");

Links

Also see these pages:

<< | DocumentationIndex | >>



This page may have a more recent version on pmwiki.org: PmWiki:MarkupVariables, and a talk page: PmWiki:MarkupVariables-Talk.

Login

Datum zadnje spremembe strani: 01 september 2005 05:18
 

© 2005-2025, Gobarsko društvo Lisička Maribor.
Ta spletna stran je last imetnika domene gobe.si, ki spletno mesto tudi upravlja. Vsebine, objavljene na spletnem mestu je dovoljeno reproducirati le v nekomercialne namene, pri čemer morajo ohraniti vsa navedena opozorila o avtorskih pravicah in se torej ne smejo prepisovati, razmnoževati ali kako drugače razširjati brez dovoljenja lastnika domene gobe.si. Po svojih najboljših močeh se trudimo, da na spletnem mestu objavljamo le prave in ažurne podatke, vendarle pa ne moremo zagotavljati popolne točnosti in zanesljivosti vseh objavljenih podatkov in povezav. Prav tako ne prevzemamo nobene odgovornosti za morebitne posledice, nastale zaradi uporabe datotek in podatkov, objavljenih na tem spletnem mestu ali začasnega nedelovanja spletnega mesta. Zavedamo se, da je zasebnost obiskovalcev naših spletnih straneh zelo pomembna. Zato ne zbiramo nobenih osebnih podatkov o obiskovalcih spletne strani gobe.si. Gobe.si si pridržuje pravico do spremembe vseh podatkov, ki so objavljeni na tem spletnem mestu. Z uporabo tega spletnega mesta obiskovalec potrjuje, da sprejema opisane pogoje in se z njimi strinja.

Stran generirana v 0.048 sekundah.