Difference between revisions of "Wikitext variables"

From www.wmwikis.net
Jump to navigation Jump to search
(Imported from Wikispaces)
 
(Imported from Wikispaces)
Line 1: Line 1:
 
+
<div id="content_view" class="wiki" style="display: block">
=Introduction=  
+
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.
+
=wikitext variables=
 
+
<div id="toc">
Variables can be used anywhere in the Wikitext, and are replaced with their values when the page is displayed. Variables take the form <nowiki>{$VARIABLENAME}`` and can optionally be modified with a modifier in the form ``{$VARIABLENAME|MODIFIERNAME}</nowiki>.
+
=Table of Contents=
 
+
<div style="margin-left: 1em">[[#Introduction| Introduction]]</div><div style="margin-left: 1em">[[#Examples| Examples]]</div><div style="margin-left: 2em">[[#Examples-Template| Template]]</div><div style="margin-left: 2em">[[#Examples-Last Edit Footer| Last Edit Footer]]</div><div style="margin-left: 1em">[[#Variable Description| Variable Description]]</div><div style="margin-left: 2em">[[#Variable Description-Namespace| Namespace]]</div><div style="margin-left: 2em">[[#Variable Description-Page| Page]]</div><div style="margin-left: 2em">[[#Variable Description-Revision| Revision]]</div><div style="margin-left: 2em">[[#Variable Description-Revision Dates| Revision Dates]]</div><div style="margin-left: 2em">[[#Variable Description-Creation| Creation]]</div><div style="margin-left: 2em">[[#Variable Description-Creation Dates| Creation Dates]]</div><div style="margin-left: 1em">[[#Modifiers| Modifiers]]</div><div style="margin-left: 2em">[[#Modifiers-Output Modifiers| Output Modifiers]]</div><div style="margin-left: 2em">[[#Modifiers-Scope Modifiers| Scope Modifiers]]</div><div style="margin-left: 1em">[[#Javascript Variables| Javascript Variables]]</div><div style="margin-left: 3em">[[#Javascript Variables--User/Space Definition Variables| User/Space Definition Variables]]</div><div style="margin-left: 3em">[[#Javascript Variables--URL Construction Variables| URL Construction Variables]]</div></div>
Variables are particularly useful when used with <nowiki>[[include page="..."]]</nowiki> and [http://www.wikispaces.com/help#templates | templates] to create customized default pages, common headers and footers, or other dynamic pages.
+
=Introduction=
 
+
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.<br /> <br />  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}.<br /> <br /> Variables are particularly useful when used with <nowiki>[[include page="..."]]</nowiki> and [http://www.wikispaces.com/help#templates templates] to create customized default pages, common headers and footers, or other dynamic pages.<br /> <br />  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.<br /> <br />
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.
+
=Examples=
 
+
==Template==
=Examples=  
+
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.<br />
==Template==  
+
<nowiki>=Product Review=
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.
+
Item Name: {$page}
<syntaxhighlight>
+
Product Website: [[http://www.a.different.website.com/{$page| url}]
=Product Review=
+
Reviewed By: {$revisioneditor}
Item Name: {$page}
+
Reviewed On: {$revisiondate}</nowiki>
Product Website: [http://www.a.different.website.com/{$page | url}]
+
==Last Edit Footer==
Reviewed By: {$revisioneditor}
+
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.<br />
Reviewed On: {$revisiondate}
+
<nowiki>----
</syntaxhighlight>
+
This page has been edited {$pagerevisions} times. The last modification was made by
==Last Edit Footer==  
+
[[user:{$revisioneditor}]] on {$revisiondate}</nowiki>
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.
+
=Variable Description=
<syntaxhighlight>
+
{| class="wiki_table"
----
+
| colspan="3" |
This page has been edited {$pagerevisions} times. The last modification was made by
+
==Namespace==
[[user:{$revisioneditor}]] on {$revisiondate}
 
</syntaxhighlight>
 
=Variable Description=  
 
{|  
 
||||| '''Namespace'''
 
 
|-
 
|-
| Space name || <nowiki>{$spacename}</nowiki> || {$spacename}
+
| Space name<br />
 +
| {$spacename}<br />
 +
| www<br />
 
|-
 
|-
| Space text || <nowiki>{$spacetext}</nowiki> || {$spacetext}
+
| Space text<br />
 +
| {$spacetext}<br />
 +
| College of William and Mary Wiki<br />
 
|-
 
|-
| Space description || <nowiki>{$spacedescription}</nowiki> || {$spacedescription}
+
| Space description<br />
 +
| {$spacedescription}<br />
 +
| <br />
 
|-
 
|-
| Page Count || <nowiki>{$pagesinspace}</nowiki> || {$pagesinspace}
+
| Page Count<br />
 +
| {$pagesinspace}<br />
 +
| 135<br />
 
|-
 
|-
| Servername (the hostname of the Wikispace) || <nowiki>{$servername}</nowiki> || {$servername}
+
| Servername (the hostname of the Wikispace)<br />
 +
| {$servername}<br />
 +
| www.wmwikis.net<br />
 
|-
 
|-
| Server (the url for the main page of the Wikispace) || <nowiki>{$server}</nowiki> || {$server}
+
| Server (the url for the main page of the Wikispace)<br />
 +
| {$server}<br />
 +
| https://www.wmwikis.net<br />
 
|-
 
|-
| License || <nowiki>{$licensename}</nowiki> || {$licensename}
+
| License<br />
 +
| {$licensename}<br />
 +
| Creative Commons Attribution Share-Alike 3.0 License<br />
 
|-
 
|-
| License URL || <nowiki>{$licenseurl}</nowiki> || {$licenseurl}
+
| License URL<br />
 +
| {$licenseurl}<br />
 +
| http://www.creativecommons.org/licenses/by-sa/3.0<br />
 
|-
 
|-
| Member Count || <nowiki>{$membersinspace}</nowiki> || {$membersinspace}
+
| Member Count<br />
 +
| {$membersinspace}<br />
 +
| 2<br />
 
|-
 
|-
| Organizer Count || <nowiki>{$organizersinspace}</nowiki> || {$organizersinspace}
+
| Organizer Count<br />
 +
| {$organizersinspace}<br />
 +
| 1<br />
 
|-
 
|-
||||| '''Page'''
+
| colspan="3" |
 +
==Page==
 
|-
 
|-
| Page Name || <nowiki>{$page}</nowiki> || {$page}
+
| Page Name<br />
 +
| {$page}<br />
 +
| About WMWikis<br />
 
|-
 
|-
| Revision count || <nowiki>{$pagerevisions}</nowiki> || {$pagerevisions}
+
| Revision count<br />
 +
| {$pagerevisions}<br />
 +
| 2<br />
 
|-
 
|-
| Full Page Name (alias for <nowiki>{$spacename}:{$page}``) || ``{$fullpagename}</nowiki> || {$fullpagename}
+
| Full Page Name (alias for {$spacename}:{$page})<br />
 +
| {$fullpagename}<br />
 +
| www:About WMWikis<br />
 
|-
 
|-
||||| '''Revision'''
+
| colspan="3" |
 +
==Revision==
 
|-
 
|-
| Editor (Username of the user, or the IP address of the guest, who created this revision) || <nowiki>{$revisioneditor}</nowiki> || {$revisioneditor}
+
| Editor (Username of the user, or the IP address of the guest, who created this revision)<br />
 +
| {$revisioneditor}<br />
 +
| wmadmin<br />
 
|-
 
|-
| Comment || <nowiki>{$revisioncomment}</nowiki> || {$revisioncomment}
+
| Comment<br />
 +
| {$revisioncomment}<br />
 +
| <br />
 
|-
 
|-
| Revision ID || <nowiki>{$revisionid}</nowiki> || {$revisionid}
+
| Revision ID<br />
 +
| {$revisionid}<br />
 +
| 199832992<br />
 
|-
 
|-
||||| '''Revision Dates'''
+
| colspan="3" |
 +
==Revision Dates==
 
|-
 
|-
| Date (In human readable format) || <nowiki>{$revisiondate}</nowiki> || {$revisiondate}
+
| Date (In human readable format)<br />
 +
| {$revisiondate}<br />
 +
| Feb 8, 2011 11:46 am<br />
 
|-
 
|-
| Day || <nowiki>{$revisionday}</nowiki> || {$revisionday}
+
| Day<br />
 +
| {$revisionday}<br />
 +
| 8<br />
 
|-
 
|-
| Day (with leading zero) || <nowiki>{$revisionday2}</nowiki> || {$revisionday2}
+
| Day (with leading zero)<br />
 +
| {$revisionday2}<br />
 +
| 08<br />
 
|-
 
|-
| Month || <nowiki>{$revisionmonth}</nowiki> || {$revisionmonth}
+
| Month<br />
 +
| {$revisionmonth}<br />
 +
| 2<br />
 
|-
 
|-
| Year || <nowiki>{$revisionyear}</nowiki> || {$revisionyear}
+
| Year<br />
 +
| {$revisionyear}<br />
 +
| 2011<br />
 
|-
 
|-
| Timestamp (In [http://en.wikipedia.org/wiki/en:ISO_8601 | ISO 8601] Format) || <nowiki>{$revisiontimestamp}</nowiki> || {$revisiontimestamp}
+
|
 +
Timestamp (In [http://en.wikipedia.org/wiki/en:ISO_8601 ISO 8601] Format)<br />
 +
| {$revisiontimestamp}<br />
 +
| 2011-02-08T19:46:42+00:00<br />
 
|-
 
|-
||||| '''Creation'''
+
| colspan="3" |
 +
==Creation==
 
|-
 
|-
| Creator(Username of the user, or the IP address of the guest, who created this page) || <nowiki>{$creator}</nowiki> || {$creator}
+
| Creator(Username of the user, or the IP address of the guest, who created this page)<br />
 +
| {$creator}<br />
 +
| wmadmin<br />
 
|-
 
|-
| Comment || <nowiki>{$creationcomment}</nowiki> || {$creationcomment}
+
| Comment<br />
 +
| {$creationcomment}<br />
 +
| <br />
 
|-
 
|-
| Creation Page ID || <nowiki>{$creationid}</nowiki> || {$creationid}
+
| Creation Page ID<br />
 +
| {$creationid}<br />
 +
| 42706373<br />
 
|-
 
|-
||||| '''Creation Dates'''
+
| colspan="3" |
 +
==Creation Dates==
 
|-
 
|-
| Date (In human readable format) || <nowiki>{$creationdate}</nowiki> || {$creationdate}
+
| Date (In human readable format)<br />
 +
| {$creationdate}<br />
 +
| Oct 20, 2008 6:54 am<br />
 
|-
 
|-
| Day || <nowiki>{$creationday}</nowiki> || {$creationday}
+
| Day<br />
 +
| {$creationday}<br />
 +
| 20<br />
 
|-
 
|-
| Day (with leading zero) || <nowiki>{$creationday2}</nowiki> || {$creationday2}
+
| Day (with leading zero)<br />
 +
| {$creationday2}<br />
 +
| 20<br />
 
|-
 
|-
| Month || <nowiki>{$creationmonth}</nowiki> || {$creationmonth}
+
| Month<br />
 +
| {$creationmonth}<br />
 +
| 10<br />
 
|-
 
|-
| Year || <nowiki>{$creationyear}</nowiki> || {$creationyear}
+
| Year<br />
|-
+
| {$creationyear}<br />
| Timestamp (In [http://en.wikipedia.org/wiki/en:ISO_8601 | ISO 8601] Format) || <nowiki>{$creationtimestamp}</nowiki> || {$creationtimestamp}
+
| 2008<br />
 
|-
 
|-
 +
|
 +
Timestamp (In [http://en.wikipedia.org/wiki/en:ISO_8601 ISO 8601] Format)<br />
 +
| {$creationtimestamp}<br />
 +
| 2008-10-20T13:54:36+00:00<br />
 
|}
 
|}
 
+
<br />
=Modifiers=  
+
=Modifiers=
Modifiers are used to change the value of the variable into a different format. Modifiers are separated from the variable name with the pipe (<nowiki>|``) character, and can be combined together. For example, ``{$pagename|ignoreinclude|url}</nowiki>
+
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}<br /> <br />  
 
+
{| class="wiki_table"
{|  
+
| colspan="3" |
||||| '''Output Modifiers'''
+
==Output Modifiers==
 
|-
 
|-
| Url escaping || <nowiki>|url (e.g. {$server|url} )</nowiki> || {$server|url}
+
| Url escaping<br />
 +
| |url (e.g. {$server|url} )<br />
 +
| https%3A%2F%2Fwww.wmwikis.net<br />
 
|-
 
|-
||||| '''Scope Modifiers'''
+
| colspan="3" |
|-
+
==Scope Modifiers==
| Ignore Include (Gets the value for the variable at the actual page that the variable lives on, possibly an included file) || <nowiki>|ignoreinclude (e.g. {$pagename|ignoreinclude} )</nowiki> || {$pagename|ignoreinclude}
 
 
|-
 
|-
 +
| Ignore Include (Gets the value for the variable at the actual page that the variable lives on, possibly an included file)<br />
 +
| |ignoreinclude (e.g. {$pagename|ignoreinclude} )<br />
 +
| wikitext variables<br />
 
|}
 
|}
 
+
<br />
=Javascript Variables=  
+
=Javascript Variables=
While editing Pages, it is possible to include Javascript inside an Embedded Object.
+
While editing Pages, it is possible to include Javascript inside an Embedded Object.<br />  Several variables can be accessed from the client side to determine the current state of the application, as follows:<br />
Several variables can be accessed from the client side to determine the current state of the application, as follows:
+
{| class="wiki_table"
{|  
+
|
| '''User/Space Definition Variables''' ||  || 
+
===User/Space Definition Variables===
|-
+
| <br />
| wikispaces_isUserLoggedIn || boolean || set if user has entered valid login information
+
| <br />
 
|-
 
|-
| wikispaces_username || string || set to current user's login handle
+
| wikispaces_isUserLoggedIn<br />
 +
| boolean<br />
 +
| set if user has entered valid login information<br />
 
|-
 
|-
| wikispaces_spaceName || string || set to current Space that user is viewing
+
| wikispaces_username<br />
 +
| string<br />
 +
| set to current user's login handle<br />
 
|-
 
|-
| '''URL Construction Variables''' ||   || 
+
| wikispaces_spaceName<br />
 +
| string<br />
 +
| set to current Space that user is viewing<br />
 
|-
 
|-
| wikispaces_method || string || system - type of function being performed ( 'view', etc. )
+
|
 +
===URL Construction Variables===
 +
| <br />
 +
| <br />
 
|-
 
|-
| wikispaces_object || string || system - type of object being viewed/modified ( 'message', etc. )  
+
| wikispaces_method<br />
 +
| string<br />
 +
| system - type of function being performed ( 'view', etc. )<br />
 
|-
 
|-
| wikispaces_page || string || set to name of current wikipage
+
| wikispaces_object<br />
 +
| string<br />
 +
| system - type of object being viewed/modified ( 'message', etc. )<br />
 
|-
 
|-
| wikispaces_id || string || system - object identifier ( for messages )
+
| wikispaces_page<br />
 +
| string<br />
 +
| set to name of current wikipage<br />
 
|-
 
|-
 +
| wikispaces_id<br />
 +
| string<br />
 +
| system - object identifier ( for messages )<br />
 
|}
 
|}
 
+
<br />  This page last edited by <span class="membersnap">- [https://www.wmwikis.net/user/view/wmadmin [[File:https:''www.wmwikis.net/user/pic/wmadmin-lg.jpg wmadmin] [https://www.wmwikis.net/user/view/wmadmin wmadmin]</span> on Feb 8, 2011 11:46 am (2 total edits) </div>
This page last edited by [[user:{$revisioneditor}]] on {$revisiondate} ({$pagerevisions} total edits)
 

Revision as of 14:29, 14 February 2019

wikitext variables

Introduction

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.

Examples

Template

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.
=Product Review= Item Name: {$page} Product Website: [[http://www.a.different.website.com/{$page| url}] Reviewed By: {$revisioneditor} Reviewed On: {$revisiondate}

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.
---- This page has been edited {$pagerevisions} times. The last modification was made by [[user:{$revisioneditor}]] on {$revisiondate}

Variable Description

Namespace

Space name
{$spacename}
www
Space text
{$spacetext}
College of William and Mary Wiki
Space description
{$spacedescription}

Page Count
{$pagesinspace}
135
Servername (the hostname of the Wikispace)
{$servername}
www.wmwikis.net
Server (the url for the main page of the Wikispace)
{$server}
https://www.wmwikis.net
License
{$licensename}
Creative Commons Attribution Share-Alike 3.0 License
License URL
{$licenseurl}
http://www.creativecommons.org/licenses/by-sa/3.0
Member Count
{$membersinspace}
2
Organizer Count
{$organizersinspace}
1

Page

Page Name
{$page}
About WMWikis
Revision count
{$pagerevisions}
2
Full Page Name (alias for {$spacename}:{$page})
{$fullpagename}
www:About WMWikis

Revision

Editor (Username of the user, or the IP address of the guest, who created this revision)
{$revisioneditor}
wmadmin
Comment
{$revisioncomment}

Revision ID
{$revisionid}
199832992

Revision Dates

Date (In human readable format)
{$revisiondate}
Feb 8, 2011 11:46 am
Day
{$revisionday}
8
Day (with leading zero)
{$revisionday2}
08
Month
{$revisionmonth}
2
Year
{$revisionyear}
2011

Timestamp (In ISO 8601 Format)

{$revisiontimestamp}
2011-02-08T19:46:42+00:00

Creation

Creator(Username of the user, or the IP address of the guest, who created this page)
{$creator}
wmadmin
Comment
{$creationcomment}

Creation Page ID
{$creationid}
42706373

Creation Dates

Date (In human readable format)
{$creationdate}
Oct 20, 2008 6:54 am
Day
{$creationday}
20
Day (with leading zero)
{$creationday2}
20
Month
{$creationmonth}
10
Year
{$creationyear}
2008

Timestamp (In ISO 8601 Format)

{$creationtimestamp}
2008-10-20T13:54:36+00:00


Modifiers

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} )
https%3A%2F%2Fwww.wmwikis.net

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} )
wikitext variables


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 - [[File:https:www.wmwikis.net/user/pic/wmadmin-lg.jpg wmadmin wmadmin on Feb 8, 2011 11:46 am (2 total edits)