Template:Gallery Section: Difference between revisions

Template page
m (initial documentation)
(auto-sort the gallery section by the images' dates, and then by title - this also excludes images that don't have a Date property (ie ones uploaded without the Upload Wizard) so be careful)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--
note that:
  {{ #vardefine: THREE | {{{2}}} {{{3}}} }} doesn't exist no matter what, so
  {{ #vardefine: THREE | {{{2}}} {{{3}}} }} doesn't exist no matter what, so
  use a work around with variables.  
  we use a work-around with variables ONE and TWO instead.  
-->{{#vardefine:ONE | {{{2}}}
-->{{#vardefine:ONE | {{{2}}}
  }}{{#vardefine:TWO | {{{3}}}
  }}{{#vardefine:TWO | {{{3}}}
Line 7: Line 8:
  }}{{#ifeq: 0 | {{#var:{{#var:THREE}} }}
  }}{{#ifeq: 0 | {{#var:{{#var:THREE}} }}
  |<!-- do nothing if no images -->
  |<!-- do nothing if no images -->
  |{{#ifeq: {{#var:ONE}} | Main Artwork
  |{{#switch:{{{4}}}
  |<!-- if this section is a Main Artwork section,
        then we sort by Date.
    -->{{#switch:{{{4}}}
         |h2=<h2>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h2>
         |h2=<h2>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h2>
         |h3=<h3>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h3>
         |h3=<h3>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h3>
      }}
  }}
      {{#ask:
  {{#ask:
        [[Category:{{{1}}}]]
    [[Category:{{{1}}}]]
        [[Category:{{{2}}}]]
    [[Category:{{{2|}}}]]
        |?caption
     [[Category:{{{3|}}}]]
        |?Date
    |?Caption
        |format=gallery
    |?Date
        |autocaptions=no
    |format=gallery
        |captionproperty=?caption
    |autocaptions=no
        |sort=Date
    |captionproperty=?Caption
        |widths=250
    |widths=250
        |limit=10000
    |limit=10000
      }}
    |sort=Date
  |<!-- else don't sort by date
    |order=asc, asc
     -->{{#switch:{{{4}}}
  }}
        |h2=<h2>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h2>
        |h3=<h3>{{#if:{{{5|}}}|{{{5}}}|{{{2}}}}}</h3>
      }}
      {{#ask:
        [[Category:{{{1}}}]]
        [[Category:{{{2}}}]]
        [[Category:{{{3|}}}]]
        |?caption
        |format=gallery
        |autocaptions=no
        |captionproperty=?caption
        |widths=250
        |limit=10000
      }}
  }}
}}</includeonly><noinclude>
}}</includeonly><noinclude>
{{Documentation}}
{{Documentation}}
</noinclude>
</noinclude>

Revision as of 17:41, 13 July 2018

Documentation icon Template documentation[view] [edit] [history] [purge]

Description

A helper/sub-template of Template:Master Gallery.

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 the category "XBlaze" -- an extraneous "XBlaze" header will not appear on Kagura's gallery page.)

Template Usage

{{ Gallery Section
  | Kagura Mutsuki  <-- {{{1}}} Image category 1 (this must be the CHARACTER'S NAME)
  | Main Artwork    <-- {{{2}}} Image category 2
  |                 <-- {{{3}}} Image Category 3 (optional)
  | h2              <-- {{{4}}} Header depth (h2, h3, h4, h5)
  | Main Artwork    <-- {{{5}}} Section header (optional, will default to {{{2}}} )

  | widths = optional gallery widths (defaults to 250) 
  | limit = optional number of items returned from the #ask query (defaults to 10000)
}}

ie. {{ Gallery Section | Kagura Mutsuki | Main Artwork | | h2 }}
ie. {{ Gallery Section | Kagura Mutsuki | Chrono Phantasma | Story | h3 | Chrono Phantasma }}

Named parameters (widths, limit) need to come after unnamed ones (positional ones) like the categories and header depth.