Template:FacetBrowser
Template page
More actions
Opens a faceted browsing wrapper around a record feed. Close it with
{{FacetBrowser/end}}. Everything between the two is the fallback: it is the
ordinary server-rendered #ask feed, it is what readers see before
MediaWiki:FacetBrowser.js finishes loading, and it is what they keep if the
script fails or JavaScript is off. Nothing about the portal depends on the script.
The script reads the configuration below from data- attributes, issues
one action=ask request for the whole record set (and one small lookup request
for each joined facet), and then filters in the browser with no further requests.
Parameters
| Parameter | Required | Meaning |
|---|---|---|
category |
see below | Category holding the records, without the namespace prefix. The script queries [[Category:<value>]]. It may be left empty when require is set: Portal:Geography does that, because its records are the pages carrying Has place type and no one category holds them all.
|
require |
see below | Property that must be present, added as [[<value>::+]]. Use it to drop records that would sort into nowhere. At least one of category, require and tally must be set.
|
sort |
no | Date property the results sort on. |
card |
no | Card renderer: news (default), research, place, tile or accession. Each of the first four emits the same DOM as the matching card template (Template:PortalNewsCard, Template:PortalResearchCard, Template:PortalPlaceCard, Template:Browse/TileCard). accession has no template: All accessions keeps its table as the fallback and loads the card styles from Template:FacetBrowser/accession.css. Its sort menu offers Latest collected, Earliest collected (an accession with no date goes last in both) and A to Z.
|
noun |
no | Plural noun for counts and empty states, for example news items.
|
lead |
no | Any value gives the newest record the full-width lead-card treatment while nothing is filtered. It reverts to an ordinary card as soon as a filter is applied. |
default |
no | The selection a reader starts from, written the way the URL fragment writes it, for example f6=Landrace-growing (several facets joined with &). It shows as ordinary filter pills the reader can remove. The portal's plain address opens on it; a reader who clears it gets #all in the address, so a reload or a shared link keeps the unfiltered view. Keep the server-rendered fallback's #ask in step with it.
|
tally |
no | Category:Property, for example Accessions:Has growing area. The record set becomes the pages in category (which may be left empty: Browse by appellation has none) or named by that property on the pages in that category (the Browse landings' own query, so a place the accessions name before its page joins the category still appears), each record is counted by the pages naming it, the sort offers Most accessions (the default) and A to Z, and the facet @tally gives With accessions / None yet. A record whose page records none of the facet properties takes them from the pages that name it.
|
link |
no | Title prefix, for example Browse by growing area/. A counted record links <prefix><title> when that page exists, and a listing of the pages naming it when it does not; an uncounted one links its own page. With card=tile the prefix also names the kind of place on the placeholder of a tile with no photo, and a tile under Browse by appellation/ shows the name without its (appellation) suffix.
|
help |
no | Page title linked as "How to query the database". |
facets |
yes | The facets, ; separated. Each is Property:Label:type. Types: enum (chips, for a small controlled vocabulary), list (searchable checklist), year (derives the year from a date property), elevation (puts a height in metres into the bands of Browse by elevation: below 500, 500–1,500, 1,500–2,500, 2,500–3,500, 3,500 m and above). A property written A+B pools both properties into one facet: Has seed storage location+Has specimen repository:Holder:list. An optional fourth part names the value a record gets when it has none, so it can still be chosen: Has country.Has landrace tier:Countries:enum:Other countries. A property written A.B is a joined facet: the record's A values (pages) are looked up among the pages that carry B, and the facet holds their B values.
|
fields |
no | Card fields, ; separated, each name:Property. The names are fixed by the renderer, see below.
|
search |
no | Comma-separated properties whose text the keyword box searches. |
Field names each renderer understands
news:date,headline,cat,summary,source,img,country,admin1,admin2,locality,region,campaignresearch:date,paper_name,paper_kind,authors,venue,year,summary,source,doi,pdf,country,growing_regiontile:img(a file name),region,admin1,country. The line under the name is the growing region (or, with none,admin1) and the country, all values listed. Use it withtallyandlink.accession:name,cls(classification),img(a file name),area,region,admin1,country,date. The card shows the page title as the accession ID, the name, the classification, the place (growing area, growing region or elseadmin1, country) and the year collected.place:type,img(a file name),country,admin1,region,subregion,min_elev,max_elev. It lists every value ofcountryandadmin1, where the other cards show the first.
Notes
- Facet values are matched with OR inside one facet and AND across facets, and each facet's counts are computed against the set filtered by every other facet, so a reader can always widen the facet they are looking at.
- Several location and agency fields hold two names crammed into one value with a semicolon. The script splits those for faceting so they do not become a bogus single value. That is a reader-side patch over a data problem, not a fix.
- The selection is mirrored into the URL fragment, so a filtered view can be linked and bookmarked. The fragment names facets by position (
#f0=,#f1=…), so once anything links a filtered view, add new facets at the end and never reorderfacets. - With
card=place, a place also counts under its own name: a country in the facet onHas country, a first-level subdivision in the facet onHas province, a growing region in the facet onHas growing region. Its page cannot store that itself, because those properties point at it from the pages below.