Template:PersonWorksSection: Difference between revisions

From Bodhicitta
(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 d-flex flex-wrap align-items-baseline justify-content-between"><span>{{{ heading | Works }}}</span><span class="text-50 opac-70 font-sans-alt font-weight-bold">{{#ask:{{{ query | }}}|format=count}}</span></div>{{#if: {{{ blurb | }}}|<div class="text-70 opac-70 mb-3 font-italic">{{{ blurb | }}}</div>|}}{{#ifexpr:{{#ask:{{{ query | }}}|format=count}}>7|<div class="row mb-3"><div class="col-md-8 col-lg-6">{{#widget:filterInput|placeholder=Filter {{#ask:{{{ query | }}}|format=count}} {{{ noun | items }}}...}}</div></div>|}}{{TileQuery
<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 with a
Renders one relationship-scoped block of works on a person page: a header carrying
live count, an optional filter box (shown once the block exceeds 7 items), and the
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>noun</code> || Plural noun used in the filter placeholder, e.g. "recordings".
|-
|-
| <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 more than once inside this template (header, filter threshold,
The count query runs twice inside this template (the visibility test and the
filter placeholder). SMW caches identical queries within a single parse, so this
header). SMW caches identical queries within a single parse, so this costs one
costs one lookup rather than three. It is written out longhand because the Variables
lookup rather than two. It is written out longhand because the Variables extension
extension is deliberately not installed on this wiki.
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.