Difference between revisions of "Template:Grid"

From TFC:TNG
Jump to navigation Jump to search
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly><span class="grid {{{class|}}}" {{ #if: {{{align|}}} | style="vertical-align: {{{align}}}" }}><span class="border"><span>{{
+
<includeonly><span class="grid" {{ #if: {{{align|}}} | style="vertical-align: {{{align}}}" }}><span class="border"><span>{{#if: {{#pos: {{{1}}} | ; }} | <span class="animated" data-imgs="{{{1}}}"> }}{{#vardefine: f| {{#explode: {{{1|}}} | ; }} }}{{#vardefine: name | {{#explode: {{#if: {{#pos: {{#var: f }} | : }} | {{#explode: {{#var: f }} | : | 1 }} | {{#var: f }} }} | , }}}}{{#vardefine: num | {{#explode: {{#var: f}} | , | 1 }}}}<span class="image {{#if: {{#pos: {{{1}}} | ; }} | active }} ">[[File:{{#var:name}}.png|{{#if:{{#var:link}}|link={{#var:link}} }}|32px]]<span class="number">{{#var: num }}</span>{{#if: {{#pos: {{{1}}} | ; }} </span>| </span> }}</span></span></span></includeonly><noinclude>
  #if: {{{default|}}} | <span class="default-image">[[File:Grid {{{default}}}.png|alt=|link=]]</span>
+
The grid template is a singular grid cell, which has the ability to display any image (usually a block or item).
}}{{#if: {{#pos: {{{1}}} | ; }} | <span class="animated" data-imgs="{{{1}}}" {{#if: {{{mod|}}} | data-mod="{{{mod}}}" }}> }}{{
 
#vardefine: f | {{#explode: {{{1|}}} | ; }}
 
}}{{
 
#vardefine: mod | {{#if: {{#pos: {{#var: f}} | : }} | {{#explode: {{#var: f}} | : }} }}
 
}}{{
 
#vardefine: mod | {{
 
  #switch: {{lc: {{#var: mod }} }}
 
  | v | vanilla =
 
  | {{#if: {{#var: mod }} | {{#var: mod }} | {{{mod|}}} }}
 
  }}
 
}}{{
 
#vardefine: name | {{#explode: {{#if: {{#pos: {{#var: f }} | : }} | {{#explode: {{#var: f }} | : | 1 }} | {{#var: f }} }} | , }}
 
}}{{
 
#vardefine: img | {{#if: {{#var: mod }} | {{#var: name }} ({{#var: mod }}) | {{#var: name }} }}
 
}}{{
 
#vardefine: num | {{#explode: {{#var: f }} | , | 1 }}
 
}}{{
 
#vardefine: link | {{
 
  #if: {{{title|}}}
 
  |
 
  | {{
 
    #if: {{{link|}}}
 
    | {{
 
      #ifeq: {{lc: {{{link|}}} }}
 
      | none |
 
      | {{{link}}}
 
      }}
 
    | {{
 
      #ifeq: {{#var: name }} | {{SUBPAGENAME}}
 
      |
 
      | {{
 
        #if: {{#var: mod }}
 
        | Mods/{{#var: mod }}/{{#var: name }}
 
        | {{#var: img }}
 
        }}
 
      }}
 
    }}
 
  }}
 
}}{{
 
#vardefine: title | {{
 
  #if: {{#var: name }} | {{
 
    #if: {{{title|}}}
 
    | {{
 
      #ifeq: {{lc: {{{title}}} }}
 
      | none |
 
      | title="{{{title}}}"
 
      }}
 
    | {{
 
      #if: {{{link|}}}
 
      | {{
 
        #ifeq: {{lc: {{{link}}} }}
 
        | none | title="{{#var: img }}"
 
        }}
 
      | {{
 
        #ifeq: {{#var: name }} | {{SUBPAGENAME}}
 
        | title="{{#var: img }}"
 
        }}
 
      }}
 
    }}
 
  }}
 
}}<span class="image {{#if: {{#pos: {{{1}}} | ; }} | active }} {{{imgclass|}}}" {{#var: title }}>{{
 
#if: {{#var: name }}
 
| [[File:Grid {{#var: img }}.png|alt={{
 
  #if: {{{title|}}}
 
  | {{
 
    #ifeq: {{lc: {{{title}}} }} | none
 
    | {{#var: img }}
 
    | {{{title}}}
 
    }}
 
  | {{#var: img }}
 
  }}|link={{#var: link }}]]{{
 
  #iferror: {{ #expr: +{{#var: num }} }}
 
  |
 
  | {{
 
    #ifexpr: {{#var: num }} > 1 and {{#var: num }} < 1000
 
    | <span class="number" {{#var: title }}>{{
 
      #if: {{#var: link }}
 
      | [[{{#var: link }}|{{#var: num }}]]
 
      | {{#var: num }}
 
      }}</span>
 
    }}
 
  }}
 
|
 
}}{{
 
#if: {{#pos: {{{1}}} | ; }} </span>| </span> }}</span></span></span></includeonly>
 
<noinclude>
 
The grid template is a singular grid cell, which has the ability to display any image (usually a block or item) that is uploaded as Grid <Name>.png, within it.
 
 
== Usage ==
 
== Usage ==
 
All inputs are optional (however Amount, Mod, Link and Title won't do anything without Name):<br>
 
All inputs are optional (however Amount, Mod, Link and Title won't do anything without Name):<br>
 
<pre style="max-width: 484px">{{Grid
 
<pre style="max-width: 484px">{{Grid
|Mod:Name,Amount
+
|Name,Amount
|mod=Default mod (useful for animations and layout templates)
 
|default=Image always shown under the main image
 
 
|align=Vertical Alignment
 
|align=Vertical Alignment
|link=Link override
 
|title=Title, removes link
 
|class=Adds additional classes to the .grid class
 
 
}}</pre>
 
}}</pre>
  
 
== Examples ==
 
== Examples ==
* To display this image [[:File:Grid Raw Porkchop.png]] with an amount of 20 you would put (2 - 999 is supported, anything else will not be displayed):
+
* To display an image with an amount of 20 (2 - 999 is supported, anything else will not be displayed):
 
+
<code><nowiki>{{Grid|Straw,20}}</nowiki></code>
<code><nowiki>{{Grid|Raw Porkchop,20}}</nowiki></code>
 
 
- The automatic link is removed if <nowiki>{{SUBPAGENAME}}</nowiki> is the same as the item name. This is to help prevent self-links, use the link parameter to re-add the link if you need it.
 
- The automatic link is removed if <nowiki>{{SUBPAGENAME}}</nowiki> is the same as the item name. This is to help prevent self-links, use the link parameter to re-add the link if you need it.
  
Line 130: Line 37:
 
<code><nowiki>{{Grid|Charcoal|link=none}}</nowiki></code>
 
<code><nowiki>{{Grid|Charcoal|link=none}}</nowiki></code>
 
- Note that this retains the title.
 
- Note that this retains the title.
 
 
* To add a different title, put:
 
<code><nowiki>{{Grid|Raw Porkchop|title=Smelly Pork}}</nowiki></code>
 
 
 
* To remove the title, set title to none:
 
<code><nowiki>{{Grid|Raw Porkchop|title=none}}</nowiki></code>
 
- Note that setting title will remove the link, due to a limitation in the software.
 
  
 
== Other templates ==
 
== Other templates ==

Latest revision as of 22:21, 20 October 2019

The grid template is a singular grid cell, which has the ability to display any image (usually a block or item).

Usage

All inputs are optional (however Amount, Mod, Link and Title won't do anything without Name):

{{Grid
|Name,Amount
|align=Vertical Alignment
}}

Examples

  • To display an image with an amount of 20 (2 - 999 is supported, anything else will not be displayed):

{{Grid|Straw,20}} - The automatic link is removed if {{SUBPAGENAME}} is the same as the item name. This is to help prevent self-links, use the link parameter to re-add the link if you need it.


  • If no image is specified, the background will be added on its own, this could be used to do layouts like so:
{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid}}{{Grid}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}<br>
{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid}}{{Grid}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}<br>
{{Grid}}{{Grid}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid}}{{Grid}}<br>
{{Grid}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid}}<br>
{{Grid}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid|Gunpowder}}{{Grid}}<br>
{{Grid}}{{Grid|Gunpowder}}{{Grid}}{{Grid}}{{Grid|Gunpowder}}{{Grid}}
  • Grids can be animated with a theoretically unlimited amount of frames, between mod items and vanilla items. Frames are separated by semi-colons (;).

{{Grid|Dirt;TNT,64;Grass Block,5;Sand;Gold Helmet,12;Redstone}}


  • Align uses the vertical-align CSS property. For example to align to the middle:

Smells like {{Grid|Raw Porkchop|align=middle}} in here!


  • To change the link from the image name put:

{{Grid|Charcoal|link=Coal#Charcoal}}


  • To remove the link, set link to none:

{{Grid|Charcoal|link=none}} - Note that this retains the title.

Other templates

These templates implement this template into a GUI screen which mimics how it would look in Minecraft. Thus, they have mostly the same features as this template. Template:Grid/See also