Difference between revisions of "Wikitext variables"

From www.wmwikis.net
Jump to: navigation, search
(Imported from Wikispaces)
(No difference)

Revision as of 14:32, 25 March 2008


Wikispaces Variables allow you to use dynamic content in your pages. That is, the content you create using variables is automatically updated to reflect some underlying information, like the number of pages in your space or the current date.

Variables can be used anywhere in the Wikitext, and are replaced with their values when the page is displayed. Variables take the form {$VARIABLENAME}`` and can optionally be modified with a modifier in the form ``{$VARIABLENAME|MODIFIERNAME}.

Variables are particularly useful when used with [[include page="..."]] and | templates to create customized default pages, common headers and footers, or other dynamic pages.

Note: Since pages are sometimes cached after being created, some items, such as the number of pages in the space, may not be updated immediately.



This example is for a simple product review template header that inserts the product name based on the page name, the reviewer and date of the review. It can be saved as a template available for new pages. <syntaxhighlight>

Product Review

Item Name: {$page} Product Website: | url} Reviewed By: {$revisioneditor} Reviewed On: {$revisiondate} </syntaxhighlight>

Last Edit Footer

This is a snippet of wikitext that can be included in a footer at the bottom of the page to show information about the last revision of the page. <syntaxhighlight>

This page has been edited {$pagerevisions} times. The last modification was made by [[user:{$revisioneditor}]] on {$revisiondate} </syntaxhighlight>

Variable Description

Space name {$spacename} {$spacename}
Space text {$spacetext} {$spacetext}
Space description {$spacedescription} {$spacedescription}
Page Count {$pagesinspace} {$pagesinspace}
Servername (the hostname of the Wikispace) {$servername} {$servername}
Server (the url for the main page of the Wikispace) {$server} {$server}
License {$licensename} {$licensename}
License URL {$licenseurl} {$licenseurl}
Member Count {$membersinspace} {$membersinspace}
Organizer Count {$organizersinspace} {$organizersinspace}
Page Name {$page} {$page}
Revision count {$pagerevisions} {$pagerevisions}
Full Page Name (alias for {$spacename}:{$page}``) || ``{$fullpagename} {$fullpagename}
Editor (Username of the user, or the IP address of the guest, who created this revision) {$revisioneditor} {$revisioneditor}
Comment {$revisioncomment} {$revisioncomment}
Revision ID {$revisionid} {$revisionid}
Revision Dates
Date (In human readable format) {$revisiondate} {$revisiondate}
Day {$revisionday} {$revisionday}
Day (with leading zero) {$revisionday2} {$revisionday2}
Month {$revisionmonth} {$revisionmonth}
Year {$revisionyear} {$revisionyear}
ISO 8601] Format) {$revisiontimestamp} {$revisiontimestamp}
Creator(Username of the user, or the IP address of the guest, who created this page) {$creator} {$creator}
Comment {$creationcomment} {$creationcomment}
Creation Page ID {$creationid} {$creationid}
Creation Dates
Date (In human readable format) {$creationdate} {$creationdate}
Day {$creationday} {$creationday}
Day (with leading zero) {$creationday2} {$creationday2}
Month {$creationmonth} {$creationmonth}
Year {$creationyear} {$creationyear}
ISO 8601] Format) {$creationtimestamp} {$creationtimestamp}


Modifiers are used to change the value of the variable into a different format. Modifiers are separated from the variable name with the pipe (|``) character, and can be combined together. For example, ``{$pagename|ignoreinclude|url}

Output Modifiers
Url escaping |url (e.g. {$server|url} ) url}
Scope Modifiers
Ignore Include (Gets the value for the variable at the actual page that the variable lives on, possibly an included file) |ignoreinclude (e.g. {$pagename|ignoreinclude} ) ignoreinclude}

Javascript Variables

While editing Pages, it is possible to include Javascript inside an Embedded Object. Several variables can be accessed from the client side to determine the current state of the application, as follows:

User/Space Definition Variables
wikispaces_isUserLoggedIn boolean set if user has entered valid login information
wikispaces_username string set to current user's login handle
wikispaces_spaceName string set to current Space that user is viewing
URL Construction Variables
wikispaces_method string system - type of function being performed ( 'view', etc. )
wikispaces_object string system - type of object being viewed/modified ( 'message', etc. )
wikispaces_page string set to name of current wikipage
wikispaces_id string system - object identifier ( for messages )

This page last edited by [[user:{$revisioneditor}]] on {$revisiondate} ({$pagerevisions} total edits)