Template:Community infobox: Difference between revisions

From NPOWiki
Jump to navigation Jump to search
(create)
 
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><table class="infobox {{#if:{{{game|}}}|{{{game}}}|othergame}}" {{#if:{{{width|}}}|{{#iferror:{{#expr:{{{width}}}}}||style="width:{{{width}}}px;"}}}}>
<includeonly>{{Format title|{{#if:{{{name|}}}|{{{name}}}|{{PAGENAME}}}}}}<table class="infobox {{#if:{{{game|}}}|{{{game}}}|othergame}}" {{#if:{{{width|}}}|style="width:{{{width}}};"}}>
<tr><th colspan="2">{{{name}}}</th></tr>
<tr><th colspan="2" class="infobox-header">{{#if:{{{name|}}}|{{{name}}}|{{#if:{{{affiliation|}}}|{{{affiliation}}}|{{PAGENAME}}}}}}</th></tr>
{{#if:{{{flag|}}}{{{flag2|}}}{{{flag3|}}}|<tr>
{{#if:{{{affiliation|}}}|{{#ifeq:{{{affiliation|}}}|{{PAGENAME}}||<tr>
<td colspan="2" class="flags">{{#if:{{{flag|}}}|
<th colspan="2" style="font-size:85%;">Government of [[{{{affiliation}}}]]</th>
     <div>[[File:{{{flag}}}|center|{{#if:{{{flag2|}}}{{{flag3|}}}|200|250}}px|Official Flag]]<br />{{#if:{{{flagdesc|}}}|{{{flagdesc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Flag}}</div>
</tr>}}}}{{#if:{{{group|}}}|{{#ifeq:{{{game}}}|torn|<tr>
<th colspan="2" style="font-size:85%;">Part of {{Tornp|{{{group}}}}}</th>
</tr>}}}}{{#if:{{{flag|}}}{{{flag2|}}}{{{flag3|}}}|<tr>
<td colspan="2" class="infobox-images">{{#if:{{{flag|}}}|
     <div>[[File:{{{flag}}}|center|{{#if:{{{flag2|}}}{{{flag3|}}}|200|250}}px|Official Flag]]{{#if:{{{flagdesc|}}}|{{{flagdesc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Flag}}</div>
}}{{#if:{{{flag2|}}}|
}}{{#if:{{{flag2|}}}|
     <div>[[File:{{{flag2}}}|center|{{#if:{{{flag|}}}{{{flag3|}}}|200|250}}px|Secondary Flag]]<br />{{#if:{{{flag2desc|}}}|{{{flag2desc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Secondary Flag}}</div>
     <div>[[File:{{{flag2}}}|center|{{#if:{{{flag|}}}{{{flag3|}}}|200|250}}px|Secondary Flag]]{{#if:{{{flag2desc|}}}|{{{flag2desc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Secondary Flag}}</div>
}}{{#if:{{{flag3|}}}|
}}{{#if:{{{flag3|}}}|
     <div>[[File:{{{flag3}}}|center|{{#if:{{{flag|}}}{{{flag2|}}}|200|250}}px|Tertiary Flag]]<br />{{#if:{{{flag3desc|}}}|{{{flag3desc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Tertiary Flag}}</div>
     <div>[[File:{{{flag3}}}|center|{{#if:{{{flag|}}}{{{flag2|}}}|200|250}}px|Tertiary Flag]]{{#if:{{{flag3desc|}}}|{{{flag3desc}}}|{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Tertiary Flag}}</div>
}}
}}
</td></tr>}}{{#if:{{{team|}}}|{{#ifeq:{{{game|}}}|cybernations|
</td></tr>}}{{#if:{{{team|}}}|{{#ifeq:{{{game|}}}|cybernations|
Line 21: Line 25:
     <th>Founded</th>
     <th>Founded</th>
     <td>{{{founded}}}</td>
     <td>{{{founded}}}</td>
</tr>}}{{#if:{{{disbanded|}}}|
<tr>
    <th>Disbanded</th>
    <td>{{{disbanded}}}</td>
</tr>}}{{#if:{{{gov1|}}}|
</tr>}}{{#if:{{{gov1|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov1name|}}}|{{{gov1name}}}|Government 1}}</th>
     <th>{{#if:{{{gov1name|}}}|{{{gov1name}}}|Government 1}}</th>
     <td>{{{gov1}}}</td>
     <td>
{{{gov1}}}
    </td>
</tr>}}{{#if:{{{gov2|}}}|
</tr>}}{{#if:{{{gov2|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov2name|}}}|{{{gov2name}}}|Government 2}}</th>
     <th>{{#if:{{{gov2name|}}}|{{{gov2name}}}|Government 2}}</th>
     <td>{{{gov2}}}</td>
     <td>
{{{gov2}}}
    </td>
</tr>}}{{#if:{{{gov3|}}}|
</tr>}}{{#if:{{{gov3|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov3name|}}}|{{{gov3name}}}|Government 3}}</th>
     <th>{{#if:{{{gov3name|}}}|{{{gov3name}}}|Government 3}}</th>
     <td>{{{gov3}}}</td>
     <td>
{{{gov3}}}
    </td>
</tr>}}{{#if:{{{gov4|}}}|
</tr>}}{{#if:{{{gov4|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov4name|}}}|{{{gov4name}}}|Government 4}}</th>
     <th>{{#if:{{{gov4name|}}}|{{{gov4name}}}|Government 4}}</th>
     <td>{{{gov4}}}</td>
     <td>
{{{gov4}}}
    </td>
</tr>}}{{#if:{{{gov5|}}}|
</tr>}}{{#if:{{{gov5|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov5name|}}}|{{{gov5name}}}|Government 5}}</th>
     <th>{{#if:{{{gov5name|}}}|{{{gov5name}}}|Government 5}}</th>
     <td>{{{gov5}}}</td>
     <td>
{{{gov5}}}
    </td>
</tr>}}{{#if:{{{gov6|}}}|
</tr>}}{{#if:{{{gov6|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov6name|}}}|{{{gov6name}}}|Government 6}}</th>
     <th>{{#if:{{{gov6name|}}}|{{{gov6name}}}|Government 6}}</th>
     <td>{{{gov6}}}</td>
     <td>
{{{gov6}}}
    </td>
</tr>}}{{#if:{{{gov7|}}}|
</tr>}}{{#if:{{{gov7|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov7name|}}}|{{{gov7name}}}|Government 7}}</th>
     <th>{{#if:{{{gov7name|}}}|{{{gov7name}}}|Government 7}}</th>
     <td>{{{gov7}}}</td>
     <td>
{{{gov7}}}
    </td>
</tr>}}{{#if:{{{gov8|}}}|
</tr>}}{{#if:{{{gov8|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov8name|}}}|{{{gov8name}}}|Government 8}}</th>
     <th>{{#if:{{{gov8name|}}}|{{{gov8name}}}|Government 8}}</th>
     <td>{{{gov8}}}</td>
     <td>
{{{gov8}}}
    </td>
</tr>}}{{#if:{{{gov9|}}}|
</tr>}}{{#if:{{{gov9|}}}|
<tr>
<tr>
     <th>{{#if:{{{gov9name|}}}|{{{gov9name}}}|Government 9}}</th>
     <th>{{#if:{{{gov9name|}}}|{{{gov9name}}}|Government 9}}</th>
     <td>{{{gov9}}}</td>
     <td>
</tr>}}{{#if:{{{teamsenate|}}}|{{#ifeq:{{{game|}}}|cybernations|
{{{gov9}}}
    </td>
</tr>}}{{#if:{{{factions|}}}|{{#ifeq:{{{game|}}}|torn|{{#if:{{{group|}}}|{{error|mixed infobox usage (factions)}}|
<tr>
    <th>Factions Operated</th>
    <td>
{{{factions}}}
    </td>
</tr>}}}}}}{{#if:{{{teamsenate|}}}|{{#ifeq:{{{game|}}}|cybernations|
<tr>
<tr>
     <th>{{#if:{{{team|}}}|{{{team}}}|Team}} Senate</th>
     <th>{{#if:{{{team|}}}|{{{team}}}|Team}} Senate</th>
     <td>{{{teamsenate}}}</td>
     <td>
{{{teamsenate}}}
    </td>
</tr>}}}}{{#if:{{{treaties|}}}|
</tr>}}}}{{#if:{{{treaties|}}}|
<tr>
<tr>
     <th>Treaties</th>
     <th>Treaties</th>
     <td>{{{treaties}}}</td>
     <td>
</tr>}}
{{{treaties}}}
    </td>
</tr>}}{{#if:{{{record|}}}{{{total|}}}{{{wins|}}}{{{losses|}}}|
<tr>
<tr>
    <th>{{#if:{{{record|}}}|{{{record}}}|War Record}}</th>
    <td><ul>{{#if:{{{total|}}}|
        <li>'''Total''': {{{total}}}</li>
    }}{{#if:{{{wins|}}}|
        <li>'''Wins''': {{{wins}}}</li>
    }}{{#if:{{{losses|}}}|
        <li>'''Losses''': {{{losses}}}</li>
    }}</ul></td>
</tr>}}<tr>
     <th>External Links</th>
     <th>External Links</th>
     <td>{{#switch:{{{game|}}}
     <td>{{#ifeq:{{#if:{{{affiliation|}}}|{{{affiliation}}}|{{PAGENAME}}}}|{{PAGENAME}}|
|cybernations=
{{#switch:{{{game|}}}
{{#if:{{{gameid|}}}|
  |cybernations=
    {{#if:{{{gameid|}}}|
*[https://www.cybernations.net/alliance_stats.asp?ID={{{gameid}}} Statistics]
*[https://www.cybernations.net/alliance_stats.asp?ID={{{gameid}}} Statistics]
*[https://www.cybernations.net/alliance_display.asp?ID={{{gameid}}} Members]
*[https://www.cybernations.net/alliance_display.asp?ID={{{gameid}}} Members]
    }}
  |nationstates=
    {{#if:{{{name|}}}|
*[https://www.nationstates.net/region={{urlencode:{{lc:{{#replace:{{#if:{{{affiliation|}}}|{{{affiliation}}}|{{{name}}}}}|<nowiki> </nowiki>|_}}}}}} Region information]
*[https://www.nationstates.net/region={{urlencode:{{lc:{{#replace:{{#if:{{{affiliation|}}}|{{{affiliation}}}|{{{name}}}}}|<nowiki> </nowiki>|_}}}}}}/page=list_nations Members]
    }}
  |torn=
    {{#if:{{{gameid|}}}|
*[https://www.torn.com/factions.php?step=profile&ID={{{gameid}}} Faction page]
    }}
}}
}}
|nationstates=
}}<!--always show the following-->{{#if:{{{forumurl|}}}|<nowiki/>
*[https://www.nationstates.net/region={{urlencode:{{lc:{{#replace:{{{name}}}|<nowiki> </nowiki>|_}}}}}} Region information]
*[{{{forumurl}}} {{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} forums]
*[https://www.nationstates.net/region={{urlencode:{{lc:{{#replace:{{{name}}}|<nowiki> </nowiki>|_}}}}}}/page=list_nations Members]
}}{{#if:{{{discordinvite|}}}|<nowiki/>
}}
{{#if:{{{forumurl|}}}|
*[{{urlencode:{{{forumurl}}}}} {{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} forums]
}}
{{#if:{{{discordinvite|}}}|
*[{{{discordinvite}}} {{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Discord]
*[{{{discordinvite}}} {{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} Discord]
}}
}}{{#ifexpr:{{#if:{{{ircserver|}}}|1|0}} and {{#if:{{{ircchannel|}}}|1|0}}|<nowiki/>
{{#ifexpr:{{#if:{{{ircserver|}}}|1|0}} and {{#if:{{{ircchannel|}}}|1|0}}|
*{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} IRC: [irc://irc.{{{ircserver}}}/{{urlencode:{{{ircchannel}}}}} #{{{ircchannel}}} on {{ucfirst:{{#explode:{{{ircserver}}}|.|0}}}}]
*{{#if:{{{acronym|}}}|{{{acronym}}}|{{{name}}}}} IRC: [{{urlencode:irc://irc.{{{ircserver}}}/{{{ircchannel}}}}} #{{{ircchannel}}} on {{#explode:{{{ircserver}}}|.|0}}]
}}
}}
</td></tr>{{#if:{{{seealso|}}}|
</td></tr>{{#if:{{{seealso|}}}|
<tr>
<tr>
     <th>See Also</th>
     <th>See Also</th>
     <td>{{{seealso|}}}</td>
     <td>
{{{seealso|}}}
    </td>
</tr>}}
</tr>}}
</table>{{#if:{{NAMESPACE}}||[[Category:{{#switch:{{{game}}}|cybernations=CN alliances|nationstates=NS regions|#default=Communities]]}}</includeonly><noinclude>{{documentation}}</noinclude>
</table>{{if ns|main|
{{#ifeq:{{#if:{{{affiliation|}}}|{{{affiliation}}}|{{PAGENAME}}}}|{{PAGENAME}}
|[[Category:{{#switch:{{{game}}}|nationstates=NationStates regions|cybernations=Cyber Nations alliances|torn=Torn {{#if:{{{factions|}}}|groups|factions}}|#default=Communities}}]]
|[[Category:{{#if:{{{game|}}}|{{abbrgame|{{{game}}}|full}} governments|Governments}}]]
}}}}</includeonly><noinclude>{{documentation}}</noinclude>

Latest revision as of 00:02, 6 July 2022

Documentation [edit]

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);
}

The above documentation is transcluded from Template:Community infobox/doc.