Template:PersonWorksSection: Difference between revisions
(VSCode edit) |
(VSCode edit) |
||
| Line 1: | Line 1: | ||
<includeonly>{{#ifexpr:{{#ask:{{{ query | }}}|format=count}}>0|<div class="person-works-section mb-5"><div class="h4 red-header mb-1 | <includeonly>{{#ifexpr:{{#ask:{{{ query | }}}|format=count}}>0|<div class="person-works-section mb-5"><div class="h4 red-header mb-1">{{#ask:{{{ query | }}}|format=count}} {{{ heading | Works }}}</div>{{#if: {{{ blurb | }}}|<div class="text-70 opac-70 mb-3 font-italic">{{{ blurb | }}}</div>|}}{{TileQuery | ||
|query={{{ query | }}} | |query={{{ query | }}} | ||
|classes=col-md-6 mb-3 mb-lg-4 | |classes=col-md-6 mb-3 mb-lg-4 | ||
| Line 13: | Line 13: | ||
== Purpose == | == Purpose == | ||
Renders one relationship-scoped block of works on a person page: a header | Renders one relationship-scoped block of works on a person page: a header carrying | ||
the count ("294 Performances & Recordings") and the tile grid itself. | |||
tile grid itself. | |||
The whole block renders nothing at all when the query returns no results, which is | The whole block renders nothing at all when the query returns no results, which is | ||
| Line 29: | Line 28: | ||
| <code>query</code> || SMW query for this section. Required. | | <code>query</code> || SMW query for this section. Required. | ||
|- | |- | ||
| <code>heading</code> || Section header text. Defaults to "Works". | | <code>heading</code> || Section header text, shown after the count. Defaults to "Works". | ||
|- | |- | ||
| <code>blurb</code> || Optional italic line under the header, to explain the relationship. | | <code>blurb</code> || Optional italic line under the header, to explain the relationship. | ||
|- | |- | ||
| <code>limit</code> || Max tiles. Defaults to 108. | | <code>limit</code> || Max tiles. Defaults to 108. | ||
| Line 39: | Line 36: | ||
| <code>sort</code> / <code>order</code> || Passed through to [[Template:TileQuery]]. | | <code>sort</code> / <code>order</code> || Passed through to [[Template:TileQuery]]. | ||
|} | |} | ||
== Filtering == | |||
This template deliberately does '''not''' emit its own filter box. | |||
[[Template:PersonCall]] places a single filter above all sections instead, which | |||
filters every section at once. | |||
That is not just a layout preference. The handler in <code>tws.js</code> binds to | |||
every <code>.filter-input</code> on the page, and an input without a | |||
<code>contentId</code> targets <code>.filterableContent</code> globally — so one box | |||
per section would leave each box filtering all the other sections too. Genuine | |||
per-section filtering would need a unique id per section plus a matching wrapper id, | |||
and is only worth it if a single person's sections ever get long enough to warrant it. | |||
== Note on counts == | == Note on counts == | ||
The count query runs | The count query runs twice inside this template (the visibility test and the | ||
header). SMW caches identical queries within a single parse, so this costs one | |||
costs one lookup rather than | lookup rather than two. It is written out longhand because the Variables extension | ||
is deliberately not installed on this wiki. | |||
</noinclude> | </noinclude> | ||
Latest revision as of 16:08, 13 August 2026
Purpose
Renders one relationship-scoped block of works on a person page: a header carrying the count ("294 Performances & Recordings") and the tile grid itself.
The whole block renders nothing at all when the query returns no results, which is what makes the hybrid layout on Template:PersonCall work — a person with only authored works gets exactly one section, while someone who both wrote and narrated gets a labelled section for each.
Parameters
| Parameter | Description |
|---|---|
query |
SMW query for this section. Required. |
heading |
Section header text, shown after the count. Defaults to "Works". |
blurb |
Optional italic line under the header, to explain the relationship. |
limit |
Max tiles. Defaults to 108. |
sort / order |
Passed through to Template:TileQuery. |
Filtering
This template deliberately does not emit its own filter box. Template:PersonCall places a single filter above all sections instead, which filters every section at once.
That is not just a layout preference. The handler in tws.js binds to
every .filter-input on the page, and an input without a
contentId targets .filterableContent globally — so one box
per section would leave each box filtering all the other sections too. Genuine
per-section filtering would need a unique id per section plus a matching wrapper id,
and is only worth it if a single person's sections ever get long enough to warrant it.
Note on counts
The count query runs twice inside this template (the visibility test and the header). SMW caches identical queries within a single parse, so this costs one lookup rather than two. It is written out longhand because the Variables extension is deliberately not installed on this wiki.