Template:Community infobox/doc: Difference between revisions
(create) |
m (→Helper) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{documentation | {{documentation subpage}} | ||
This template is meant to be "implemented" by other templates, but can be used directly if needed. Implementations must specify the game name and pass through any relevant parameters, or custom formatted information. They must be updated if the available parameters are changed. | This template is meant to be "implemented" by other templates, but can be used directly if needed. Implementations must specify the game name and pass through any relevant parameters, or custom formatted information (for freeform fields). They must be updated if the available parameters are changed. | ||
For a list of current implementations, <span class="plainlinks">[{{fullurl:Special:WhatLinksHere|target=Template:Community_infobox&namespace=10}} see here]</span>. | For a list of current implementations, <span class="plainlinks">[{{fullurl:Special:WhatLinksHere|target=Template:Community_infobox&namespace=10}} see here]</span>. | ||
==Usage== | |||
Normally, this can be used directly on the page for a community. However, if there is a separate page for the government structure, we want to reduce duplication. This template should be used on the government page with the <code>affiliation</code> parameter and onlyinclude tags, and then the current government's page can be transcluded on the community's page. It looks like this: | |||
*On "New Pacific Order in NationStates": | |||
<pre> | |||
<onlyinclude>{{NS region infobox | |||
|affiliation = The Pacific | |||
... | |||
}}</onlyinclude> | |||
</pre> | |||
*On "The Pacific": | |||
<pre>{{:New Pacific Order in NationStates}}</pre> | |||
The affiliation parameter is required to categorize the page as a government properly and determine what information to display on each page. It is not required when the template is used directly on a community page. A government page can have multiple infoboxes, as long as only the current one has the onlyinclude tags. | |||
==Available parameters== | ==Available parameters== | ||
*'''game''' - can be one of: cybernations, nationstates, othergame (default). | *'''game''' - can be one of: cybernations, nationstates, torn, othergame (default). | ||
*'''width''' - of infobox; use sparingly. Currently not available in implementations. | *'''width''' - of infobox; use sparingly. Currently not available in implementations. | ||
*'''name''' | *'''name''' | ||
*'''group''' - Torn only, the group that operates this faction. Name only. | |||
*'''affiliation''' - for use on government pages. The name of the associated page. | |||
*'''acronym''' | *'''acronym''' | ||
*'''gameid''' - CN only, the | *'''gameid''' - CN and Torn only, the ID in game | ||
*'''flag''' - file name and extension | *'''flag''' - file name and extension only | ||
*'''flagdesc''' | *'''flagdesc''' | ||
*'''flag2''' | *'''flag2''' | ||
Line 20: | Line 36: | ||
*'''foundedby''' | *'''foundedby''' | ||
*'''founded''' | *'''founded''' | ||
*'''disbanded''' | |||
*'''gov1name''' through '''gov9name''' - the heading for the matching list | |||
*'''gov1''' through '''gov9''' - freeform area | *'''gov1''' through '''gov9''' - freeform area | ||
*''' | *'''factions''' - Torn only: if this is a group operating multiple factions, list those factions here (preferably internal links). This will categorize the page as a group. | ||
*'''teamsenate''' - CN only, supported team senators | *'''teamsenate''' - CN only, supported team senators | ||
*'''treaties''' - freeform area | *'''treaties''' - freeform area | ||
*'''forumurl''' | *'''record''' - the heading for the records row | ||
*'''total''' - the total number of items for the records row | |||
*'''wins''' | |||
*'''losses''' | |||
*'''forumurl''' - full url | |||
*'''discordinvite''' - full url | *'''discordinvite''' - full url | ||
*'''ircserver''' - e.g. coldfront.net | *'''ircserver''' - e.g. coldfront.net | ||
*'''ircchannel''' - no # sign | *'''ircchannel''' - no # sign | ||
*'''seealso''' - freeform area, | *'''seealso''' - freeform area, important internal wikilinks only. | ||
==Skeleton== | ==Skeleton== | ||
Line 35: | Line 57: | ||
|width = | |width = | ||
|name = | |name = | ||
|group = | |||
|affiliation = | |||
|acronym = | |acronym = | ||
|gameid = | |gameid = | ||
Line 46: | Line 70: | ||
|foundedby = | |foundedby = | ||
|founded = | |founded = | ||
|disbanded = | |||
|gov1name = | |||
|gov1 = | |gov1 = | ||
| | |gov2name = | ||
|gov2 = | |gov2 = | ||
| | |gov3name = | ||
|gov3 = | |gov3 = | ||
| | |gov4name = | ||
|gov4 = | |gov4 = | ||
| | |gov5name = | ||
|gov5 = | |gov5 = | ||
| | |gov6name = | ||
|gov6 = | |gov6 = | ||
| | |gov7name = | ||
|gov7 = | |gov7 = | ||
| | |gov8name = | ||
|gov8 = | |gov8 = | ||
| | |gov9name = | ||
|gov9 = | |gov9 = | ||
| | |factions = | ||
|teamsenate = | |teamsenate = | ||
|treaties = | |treaties = | ||
|record = | |||
|total = | |||
|wins = | |||
|losses = | |||
|forumurl = | |forumurl = | ||
|discordinvite = | |discordinvite = | ||
Line 75: | Line 105: | ||
==Helper== | ==Helper== | ||
To generate code for an implementation, you can use this script in your browser console. Call it with an array of parameter names, which you can obtain from the skeleton above. | To generate code for an implementation, you can use this script in your browser console. Call it with an array of parameter names, which you can obtain from the skeleton above. | ||
< | <syntaxhighlight lang="javascript"> | ||
function | function build(params) { | ||
var out = '' | var out = '' | ||
for (var i = 0; i < | for (var i = 0; i < params.length; i++) { | ||
out += '\n|' + | out += '\n|' + params[i] + ' = {{{' + params[i] + '|}}}'; | ||
} | } | ||
console.log(out); | console.log(out); | ||
} | } | ||
</ | </syntaxhighlight> | ||
<includeonly>[[Category:Infobox templates]]</includeonly> | <includeonly>[[Category:Infobox templates]]</includeonly> |
Latest revision as of 20:29, 4 August 2024
This template is meant to be "implemented" by other templates, but can be used directly if needed. Implementations must specify the game name and pass through any relevant parameters, or custom formatted information (for freeform fields). They must be updated if the available parameters are changed.
For a list of current implementations, see here.
Usage
Normally, this can be used directly on the page for a community. However, if there is a separate page for the government structure, we want to reduce duplication. This template should be used on the government page with the affiliation
parameter and onlyinclude tags, and then the current government's page can be transcluded on the community's page. It looks like this:
- On "New Pacific Order in NationStates":
<onlyinclude>{{NS region infobox |affiliation = The Pacific ... }}</onlyinclude>
- On "The Pacific":
{{:New Pacific Order in NationStates}}
The affiliation parameter is required to categorize the page as a government properly and determine what information to display on each page. It is not required when the template is used directly on a community page. A government page can have multiple infoboxes, as long as only the current one has the onlyinclude tags.
Available parameters
- game - can be one of: cybernations, nationstates, torn, othergame (default).
- width - of infobox; use sparingly. Currently not available in implementations.
- name
- group - Torn only, the group that operates this faction. Name only.
- affiliation - for use on government pages. The name of the associated page.
- acronym
- gameid - CN and Torn only, the ID in game
- flag - file name and extension only
- flagdesc
- flag2
- flag2desc
- flag3
- flag3desc
- team - CN only
- foundedby
- founded
- disbanded
- gov1name through gov9name - the heading for the matching list
- gov1 through gov9 - freeform area
- factions - Torn only: if this is a group operating multiple factions, list those factions here (preferably internal links). This will categorize the page as a group.
- teamsenate - CN only, supported team senators
- treaties - freeform area
- record - the heading for the records row
- total - the total number of items for the records row
- wins
- losses
- forumurl - full url
- discordinvite - full url
- ircserver - e.g. coldfront.net
- ircchannel - no # sign
- seealso - freeform area, important internal wikilinks only.
Skeleton
{{Community infobox |game = |width = |name = |group = |affiliation = |acronym = |gameid = |flag = |flagdesc = |flag2 = |flag2desc = |flag3 = |flag3desc = |team = |foundedby = |founded = |disbanded = |gov1name = |gov1 = |gov2name = |gov2 = |gov3name = |gov3 = |gov4name = |gov4 = |gov5name = |gov5 = |gov6name = |gov6 = |gov7name = |gov7 = |gov8name = |gov8 = |gov9name = |gov9 = |factions = |teamsenate = |treaties = |record = |total = |wins = |losses = |forumurl = |discordinvite = |ircserver = |ircchannel = |seealso = }}
Helper
To generate code for an implementation, you can use this script in your browser console. Call it with an array of parameter names, which you can obtain from the skeleton above.
function build(params) {
var out = ''
for (var i = 0; i < params.length; i++) {
out += '\n|' + params[i] + ' = {{{' + params[i] + '|}}}';
}
console.log(out);
}