Template:Cargo query
Jump to navigation
Jump to search
Documentation
This template provides a centralized, future-proof wrapper function for making Cargo queries of HopperWiki's Cargo tables. It outputs a sortable, responsive, and collapsible HTML table with support for advanced field rendering, aliases, and styling.
This system allows you to run complex Cargo queries while separating display formatting from data logic. It automatically supports collapsing long tables and truncating long field content, and can intelligently format fields of type `File`, `List of page`, `List of file`, and more.
Parameters
- cargo_table
- Name of the Cargo table to query. **(required)**
- cargo_fields
- Comma-separated list of fields to retrieve in the query. Aliases using `=` are supported (e.g., `CONCAT('[', Link, ']') = View_Link`).
- cargo_display_fields
- Optional. Comma-separated list of fields or aliases to display as table columns. Defaults to `cargo_fields`.
- cargo_where
- SQL-style `WHERE` clause to filter results. Use standard Cargo syntax such as `HOLDS`, `LIKE`, etc.
- row_cutoff
- Optional. Integer. If more than this many rows are returned, the table is collapsed and a "Show more" button is added. Default: `10`.
- character_cutoff
- Optional. Integer. Truncates long string fields beyond this character count with an ellipsis (`…`). Default: `600`.
Example usage
{{Cargo_query |cargo_table=Resource |cargo_fields=English_short_title, CONCAT('[', Resource_link, ']') = URL, Geographic_purview, Category, Descriptive_keyword, Author, Language, Species_purview |cargo_display_fields=English_short_title, URL, Geographic_purview, Category, Descriptive_keyword, Author, Language, Species_purview |cargo_where=Category HOLDS "Guide" AND Descriptive_keyword HOLDS "Species Identification" |row_cutoff=5 |character_cutoff=300 }}
This example displays a list of guides related to species identification, with clickable URLs and collapsibility enabled after 5 rows.