W3TPL/sysdata: Difference between revisions
< W3TPL
Jump to navigation
Jump to search
(Created page with '==About== "Sysvar" syntax is a way of accessing various bits of information provided by the system under different circumstances. Any value prefixed with "@" will be treated as a…') |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==About== | ==About== | ||
" | "Sysdata" syntax is a way of accessing various bits of information provided by the system under different circumstances. Any value prefixed with "@" will be treated as a reference to system data. | ||
Note that this syntax can only be used in contexts where a ''value'' is expected (<code>val=</code>), not a ''variable'' (<code>copy=</code>). | |||
==Names== | ==Names== | ||
* @'''title''': information about the current page title | * @'''title''': information about the current page title | ||
** .'''id''': the article ID | ** .'''id''': the article ID | ||
** .'''full': namespace:subject | ** .'''full''': namespace:subject | ||
** .'''subject': just the part after the namespace and before any slashes (i.e. not the subpage name) | ** .'''subject''': just the part after the namespace and before any slashes (i.e. not the subpage name) | ||
** .'''name': just the part after the namespace (including any subpages) | ** .'''name''': just the part after the namespace (including any subpages) | ||
** .'''url': URL for the page | ** .'''url''': URL for the page | ||
* @'''user''': information about the user currently viewing the page | * @'''user''': information about the user currently viewing the page | ||
** .'''login''': user's login -- $wgUser->getName() | ** .'''login''': user's login -- $wgUser->getName() | ||
** .'''dbkey''': user's login in URL format -- $wgUser->getTitleKey(); | ** .'''dbkey''': user's login in URL format -- $wgUser->getTitleKey(); | ||
** .'''id''': user's database ID -- $wgUser->getID(); | ** .'''id''': user's database ID -- $wgUser->getID(); | ||
** .'''can''': user has permission to do specified action? -- $wgUser->isAllowed(''action''); | ** .'''can'''.''action'': user has permission to do specified action? -- $wgUser->isAllowed(''action''); | ||
** .'''rights''': user rights -- $wgUser->getRights(), converted to a [[prefix-separated list]] | ** .'''rights''': user rights -- $wgUser->getRights(), converted to a [[prefix-separated list]] | ||
** .'''email''': user's email address, if known)-- $wgUser->getEmail() | ** .'''email''': user's email address, if known)-- $wgUser->getEmail() | ||
** .'''name''': user's full name, if known -- $out = $wgUser->getRealName(); | ** .'''name''': user's full name, if known -- $out = $wgUser->getRealName(); | ||
* @'''query'''.''name'': value of $_GET["''name''"] | * @'''w3ext''': information about the extension | ||
* | ** .'''docurl''': URL to documentation, from {{l/htyp|extension.json}} file | ||
===currently unsupported=== | |||
* @'''row''': information about the current data row | |||
** .'''name''': name of the field (column) to access | |||
* @'''mem''': current memory usage, for debugging (this is a kluge and should probably be made more useful or eliminated) | |||
* @'''query''': DEPRECATED - use @http.get | |||
* @'''post''': DEPRECATED - use @http.post | |||
* @'''http''': information about the [[http request]] | |||
** .'''get'''.''name'': value of $_GET["''name''"] | |||
** .'''post'''.''name'': value of $_POST["''name''"] | |||
** .'''req'''.''name'': value of $wgRequest->getVal(''name'') -- this function is available via the <code>arg=</code> attribute | |||
* @'''env'''.''name'': value of $_ENV["''name''"] | * @'''env'''.''name'': value of $_ENV["''name''"] | ||
* @'''sql''': the last SQL statement executed by W3TPL (for debugging) | * @'''sql''': the last SQL statement executed by W3TPL (for debugging) | ||
==Examples== | ==Examples== | ||
<xml> | <syntaxhighlight lang=xml> | ||
<let name=pg_title val="@row.page_title" /> | <let name=pg_title val="@row.page_title" /> | ||
</ | <let name=action val="@http.get.action" /> | ||
<get val=@user.login /> | |||
</syntaxhighlight> | |||
The first two lines set variables from sysdata; the third line just displays the sysdata value. | |||
==History== | |||
* '''2010-09-11''' Finally some documentation; decided to deprecate @query and @post in favor of @http.* |
Latest revision as of 15:59, 3 May 2022
About
"Sysdata" syntax is a way of accessing various bits of information provided by the system under different circumstances. Any value prefixed with "@" will be treated as a reference to system data.
Note that this syntax can only be used in contexts where a value is expected (val=
), not a variable (copy=
).
Names
- @title: information about the current page title
- .id: the article ID
- .full: namespace:subject
- .subject: just the part after the namespace and before any slashes (i.e. not the subpage name)
- .name: just the part after the namespace (including any subpages)
- .url: URL for the page
- @user: information about the user currently viewing the page
- .login: user's login -- $wgUser->getName()
- .dbkey: user's login in URL format -- $wgUser->getTitleKey();
- .id: user's database ID -- $wgUser->getID();
- .can.action: user has permission to do specified action? -- $wgUser->isAllowed(action);
- .rights: user rights -- $wgUser->getRights(), converted to a prefix-separated list
- .email: user's email address, if known)-- $wgUser->getEmail()
- .name: user's full name, if known -- $out = $wgUser->getRealName();
- @w3ext: information about the extension
- .docurl: URL to documentation, from extension.json file
currently unsupported
- @row: information about the current data row
- .name: name of the field (column) to access
- @mem: current memory usage, for debugging (this is a kluge and should probably be made more useful or eliminated)
- @query: DEPRECATED - use @http.get
- @post: DEPRECATED - use @http.post
- @http: information about the http request
- .get.name: value of $_GET["name"]
- .post.name: value of $_POST["name"]
- .req.name: value of $wgRequest->getVal(name) -- this function is available via the
arg=
attribute
- @env.name: value of $_ENV["name"]
- @sql: the last SQL statement executed by W3TPL (for debugging)
Examples
<let name=pg_title val="@row.page_title" />
<let name=action val="@http.get.action" />
<get val=@user.login />
The first two lines set variables from sysdata; the third line just displays the sysdata value.
History
- 2010-09-11 Finally some documentation; decided to deprecate @query and @post in favor of @http.*