History Source of this version Current version
| 1 | --- | |
| 2 | title: Wiki Data | |
| 3 | tags: [Building] | |
| 4 | --- | |
| 5 | | |
| 6 | Wiki Data gives authors a central place to store and organise data sets of any kind. Data is defined for the whole wiki and every component on the wiki can use it: change the data, and every component showing it, and every page using those components, updates automatically. | |
| 7 | | |
| 8 | For example: | |
| 9 | | |
| 10 | - every character in a hero shooter, with their class and stats; | |
| 11 | - every episode of a TV show, with its title, season, air date and description; | |
| 12 | - every creature in a collectible card game, with its cost, type and abilities. | |
| 13 | | |
| 14 | Trusted editors find it under **Wiki data** in the sidebar, next to Files and Emotes. | |
| 15 | | |
| 16 | ## Two kinds | |
| 17 | | |
| 18 | - **Table:** columns with a name and a type (text, number, yes/no, page, file) and a row per entry, edited like a small spreadsheet. Paste rows from a spreadsheet into any cell. Cells are checked as you type: a number column won't take "lots". | |
| 19 | - **YAML:** any shape: lists, groups, nesting. Numbers stay numbers, `[[Page]]` is a page and `media:name` a file. | |
| 20 | | |
| 21 | A set's name is how components read it (`$data.weapons`) and can't change. | |
| 22 | | |
| 23 | Sets are edited on the same workbench as articles and components: the grid or the YAML on one side, and on the other what components will read, with numbers, pages and files as they'll get them. The same checks as saving run as you type; anything that won't save is a note, and one count in the bar opens the list (a bad cell takes you to it). **Save…** says how many entries changed and asks what changed and why. In YAML, Enter lines up under an entry's fields, and **Insert** writes an entry, a page or a file. | |
| 24 | | |
| 25 | ## In a component | |
| 26 | | |
| 27 | Components read a set as `$data.name`. The component editor knows the wiki's data: type `$data.` and it offers every set, with how many entries each has and its columns; inside `$for={w in $data.weapons}`, type `w.` and it offers that set's columns. Spell a set's name wrong and it's flagged straight away. | |
| 28 | | |
| 29 | :::screenshot[Completing a data set's columns in the component editor]{url="apex.fanforge.wiki/c/s0ph1r/edit"} | |
| 30 |  | |
| 31 | ::: | |
| 32 | | |
| 33 | A table is a list of records, one per row: | |
| 34 | | |
| 35 | ```fsx | |
| 36 | <component> | |
| 37 | <ul> | |
| 38 | <li $for={w in $data.weapons | sort: "damage" | reverse}> | |
| 39 | {w.name}: {w.damage} | |
| 40 | </li> | |
| 41 | </ul> | |
| 42 | </component> | |
| 43 | ``` | |
| 44 | | |
| 45 | ## Changes | |
| 46 | | |
| 47 | Each save is a version: the set's page lists them and shows what changed, and anyone who can change the set can restore an old one. Moderators can bring back a deleted set. Edits appear in **Recent changes** like page edits, and rolling back someone's edits covers their data changes too. Admins can limit a much-used set to admins. |