Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Chao: Difference between revisions

17,076 editsJoined 5 November 2017
(gallery working demo)
m (test gallery with three categories)
Line 1: Line 1:
<includeonly>
<includeonly>{{#if:{{{3|}}}
{{#switch: {{{2}}}
   |{{#vardefine:cat3 | [[Category:{{{3}}}]] }}
   | Main Artwork = {{#vardefine:category|Main Artwork}}
   |{{#vardefine:cat3 | }}
  | Battle = {{#vardefine:category|Battle}}
}}{{#ifeq: 0 | {{#ask:
   | {{#vardefine:category|NULL}}
     [[Category:{{{1}}}]]
}}
     [[Category:{{{2}}}]]
{{#vardefine: {{{2}}} |
    {{#var:cat3}}
  {{#ask:
     [[Category: {{{1}}} ]]
     [[Category: {{#var:category}} ]]
     | format=count
     | format=count
   }}
   }}
}}{{#ifeq: 0 | {{#var: {{{2}}} }} | <!-- do nothing if no images --> |
|<!-- do nothing if no images -->
  {{#switch:{{{3}}}
|{{#switch:{{{4}}}
     |h2=<h2>{{{2}}}</h2>
     |h2=<h2>{{{5}}}</h2>
     |h3=<h3>{{{2}}}</h3>
     |h3=<h3>{{{5}}}</h3>
   }}
   }}
   {{#ask:
   {{#ask:
     [[Category:{{{1}}}]]
     [[Category:{{{1}}}]]
     [[Category:{{#var:category}}]]
     [[Category:{{{2}}}]]
    {{#var:cat3}}
     |?caption
     |?caption
     |format=gallery
     |format=gallery
Line 24: Line 22:
     |captionproperty=?caption
     |captionproperty=?caption
     |perrow=7
     |perrow=7
    |overlay=yes
   }}
   }}
}}
}}</includeonly><noinclude>
</includeonly><noinclude>


{{TOC}}
{{TOC}}
Line 33: Line 29:
<syntaxhighlight>
<syntaxhighlight>
<!-- MAIN ARTWORK -->
<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | h2 }}
{{ User:Chao | {{{1}}} | Main Artwork | | h2 | Main Artwork }}


<!-- SPRITES -->
<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
{{#ifeq: 0 | {{#expr:
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Battle]]|format=count}} +
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Palette Reference]]|format=count}} +  
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Portraits]]|format=count}}
  }}
   | <!-- all three subcategories are empty, don't make a section header-->
   | <!-- all three subcategories are empty, don't make a section header-->
   | <h2> Sprites </h2>  
   | <h2> Sprites </h2>  
     {{ User:Chao | {{{1}}} | Battle | h3 }}
     {{ User:Chao | Kagura Mutsuki | Battle | | h3 | Battle }}
     {{ User:Chao | {{{1}}} | Palette Reference | h3 }}
     {{ User:Chao | Kagura Mutsuki | Palette Reference | | h3 | Palette Reference }}
     {{ User:Chao | {{{1}}} | Third Category | h3 }}
     {{ User:Chao | Kagura Mutsuki | Portraits | | h3 | Portraits }}
}}
}}


...
Works for multiple categories (here, "Kagura Mutsuki", "Story", and (the optional) "Chrono Phantasma")
 
{{ User:Chao | Kagura Mutsuki | Story | Chrono Phantasma | h2 | Chrono Phantasma }}
<!-- and so on with other categories and sub-categories -->
</syntaxhighlight>
</syntaxhighlight>
<b>This code will produce:</b>


<!-- MAIN ARTWORK -->
<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | h2 }}
{{ User:Chao | {{{1}}} | Main Artwork | | h2 | Main Artwork }}


<!-- SPRITES -->
<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
{{#ifeq: 0 | {{#expr:
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Battle]]|format=count}} +
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Palette Reference]]|format=count}} +  
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Portraits]]|format=count}}
  }}
   | <!-- all three subcategories are empty, don't make a section header-->
   | <!-- all three subcategories are empty, don't make a section header-->
   | <h2> Sprites </h2>  
   | <h2> Sprites </h2>  
     {{ User:Chao | {{{1}}} | Battle | h3 }}
     {{ User:Chao | Kagura Mutsuki | Battle | | h3 | Battle }}
     {{ User:Chao | {{{1}}} | Palette Reference | h3 }}
     {{ User:Chao | Kagura Mutsuki | Palette Reference | | h3 | Palette Reference }}
     {{ User:Chao | {{{1}}} | Third Category | h3 }}
     {{ User:Chao | Kagura Mutsuki | Portraits | | h3 | Portraits }}
}}
}}


...
{{ User:Chao | Kagura Mutsuki | Story | Chrono Phantasma | h2 | Chrono Phantasma }}
 


== Technical Notes ==
== Technical Notes ==
Line 79: Line 81:
==== Template Code ====
==== Template Code ====
<syntaxhighlight>
<syntaxhighlight>
<!-- MAIN ARTWORK -->
<!-- MAIN ARTWORK -->
{{ Gallery Section | {{{1}}} | Main Artwork | h2 }}
{{ Gallery Section | {{{1}}} | Main Artwork | | h2 | Main Artwork }}


<!-- SPRITES -->
<!-- SPRITES -->
Line 86: Line 89:
   | <!-- all three subcategories are empty, don't make a section header-->
   | <!-- all three subcategories are empty, don't make a section header-->
   | <h2> Sprites </h2>  
   | <h2> Sprites </h2>  
     {{ Gallery Section | {{{1}}} | Battle | h3 }}
     {{ Gallery Section | {{{1}}} | Battle | | h2 | Battle }}
     {{ Gallery Section | {{{1}}} | Palette Reference | h3 }}
     {{ Gallery Section | {{{1}}} | Palette Reference | | h3 | Palette Reference }}
     {{ Gallery Section | {{{1}}} | Third Category | h2 }}
     {{ Gallery Section | {{{1}}} | Portraits | | h2 | Portraits }}
}}
}}


Line 104: Line 107:
<syntaxhighlight>
<syntaxhighlight>
{{ Gallery Section
{{ Gallery Section
   | Kagura Mutsuki  <-- Character name
   | Kagura Mutsuki  <-- {{{1}}} Character name (Image category 1)
   | Main Artwork    <-- Section header. Doubles as the category in which images will be searched for.
   | Main Artwork    <-- {{{2}}} Image Category 2
   | h2              <-- Header depth (h2, h3, h4, h5)
  |                <-- {{{3}}} Optional Image Category 3
   | h2              <-- {{{4}}} Header depth (h2, h3, h4, h5)
  | Main Artwork    <-- {{{5}}} Section header.
}}
}}


ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | h2 }}
ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | | h2 | Main Artwork }}
</syntaxhighlight>
</syntaxhighlight>


==== Template Code ====
==== Template Code ====
<syntaxhighlight>
<syntaxhighlight>
{{#vardefine: {{{2}}} |
{{#vardefine: {{{2}}} {{{3}}} |
   {{#ask:
   {{#ask:
     [[Category: {{{1}}} ]]
     [[Category: {{{1}}} ]]
     [[Category: {{{2}}} ]]
     [[Category: {{{2}}} ]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
     | format=count
     | format=count
   }}
   }}
}}{{#ifeq: 0 | {{#var: {{{2}}} }} | <!-- do nothing if no images --> |
}}{{#ifeq: 0 | {{#var: {{{2}}} {{{3}}} }} | <!-- do nothing if no images --> |
   {{#switch:{{{3}}}
   {{#switch:{{{4}}}
     |h2=<h2>{{{2}}}</h2>
     |h2=<h2>{{{5}}}</h2>
     |h3=<h3>{{{2}}}</h3>
     |h3=<h3>{{{5}}}</h3>
   }}
   }}
   {{#ask:
   {{#ask:
     [[Category:{{{1}}}]]
     [[Category:{{{1}}}]]
     [[Category:{{{2}}}]]
     [[Category:{{{2}}}]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
     |?caption
     |?caption
     |format=gallery
     |format=gallery

Revision as of 08:28, 9 November 2017


<!-- MAIN ARTWORK -->
{{ User:Chao | {{{1}}} | Main Artwork | | h2 | Main Artwork }}

<!-- SPRITES -->
{{#ifeq: 0 | {{#expr:
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Battle]]|format=count}} +
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Palette Reference]]|format=count}} + 
  {{#ask:[[Category:Kagura Mutsuki]][[Category:Portraits]]|format=count}}
  }}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2> 
    {{ User:Chao | Kagura Mutsuki | Battle | | h3 | Battle }}
    {{ User:Chao | Kagura Mutsuki | Palette Reference | | h3 | Palette Reference }}
    {{ User:Chao | Kagura Mutsuki | Portraits | | h3 | Portraits }}
}}

Works for multiple categories (here, "Kagura Mutsuki", "Story", and (the optional) "Chrono Phantasma")
{{ User:Chao | Kagura Mutsuki | Story | Chrono Phantasma | h2 | Chrono Phantasma }}

Main Artwork

... further results

Sprites

Battle

Portraits



Technical Notes

Template: Gallery

Creates a gallery from template for the specified character. It will skip sections and subsections that the character does not have images for.

Template Usage

   {{ Gallery | {{PAGENAME}} }}   <-- with the idea that {{PAGENAME}} will evaluate to ie. Kagura Mutsuki
OR {{ Gallery | Kagura Mutsuki }} <-- this will also work

Template Code

<!-- MAIN ARTWORK -->
{{ Gallery Section | {{{1}}} | Main Artwork | | h2 | Main Artwork }}

<!-- SPRITES -->
{{#ifeq: 0 | {{#var:Battle}} + {{#var:Palette Reference}} + {{#var:Third Category}}
  | <!-- all three subcategories are empty, don't make a section header-->
  | <h2> Sprites </h2> 
    {{ Gallery Section | {{{1}}} | Battle | | h2 | Battle }}
    {{ Gallery Section | {{{1}}} | Palette Reference | | h3 | Palette Reference }}
    {{ Gallery Section | {{{1}}} | Portraits | | h2 | Portraits }}
}}

...

<!-- and so on with other categories and sub-categories -->

Template: Gallery Section

Creates a section header with the specified depth (h2, h3, h4, h5), and a gallery of all images that contain the two specified tags. If there are no images in the specified gallery, this code will not do anything. (That is, it is safe to call even when "Kagura Mutsuki" does not have images in "XBlaze" -- an extraneous "XBlaze" header will not appear on Kagura's gallery page.)

Template Usage

{{ Gallery Section
  | Kagura Mutsuki  <-- {{{1}}} Character name (Image category 1)
  | Main Artwork    <-- {{{2}}} Image Category 2
  |                 <-- {{{3}}} Optional Image Category 3
  | h2              <-- {{{4}}} Header depth (h2, h3, h4, h5)
  | Main Artwork    <-- {{{5}}} Section header. 
}}

ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | | h2 | Main Artwork }}

Template Code

{{#vardefine: {{{2}}} {{{3}}} |
  {{#ask:
    [[Category: {{{1}}} ]]
    [[Category: {{{2}}} ]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
    | format=count
  }}
}}{{#ifeq: 0 | {{#var: {{{2}}} {{{3}}} }} | <!-- do nothing if no images --> |
  {{#switch:{{{4}}}
    |h2=<h2>{{{5}}}</h2>
    |h3=<h3>{{{5}}}</h3>
  }}
  {{#ask:
    [[Category:{{{1}}}]]
    [[Category:{{{2}}}]]
    {{#if:{{{3|}}}
      | [[Category: {{{3}}} ]] | }}
    |?caption
    |format=gallery
    |autocaptions=no
    |captionproperty=?caption
    |perrow=7
    |overlay=yes
  }}
}}



Useful References

Modules

Semantic MediaWiki

DPL

Other things to look into later:

Note: I believe it"s good wikimedia practice to use only ==H2== and beyond (in essence, to avoid using =H1=)