Jump to content

ICT:Cargo and PageForms

From Costa Sano MediaWiki
Revision as of 13:24, 5 January 2026 by Mngr (talk | contribs) (Cargo with PageFrom workflow)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Cargo and Page Forms Implementation Guide (2026)

This guide explains how to set up a structured data system using the Cargo and Page Forms extensions in MediaWiki 1.45.

1. The Data Schema (Template:Book)

The template is the "brain" of the operation. It declares the database structure and stores the data when a page is saved.

Path: Template:Book

<noinclude>
{{#cargo_declare:
_table = Books
|Title = String
|Author = String
|Year = Integer
}}
This template is used to store book metadata in the Cargo database.
</noinclude>
<includeonly>
{{#cargo_store:
_table = Books
}}
{| class="wikitable" style="width: 300px;"
! Title
| {{{Title|}}}
|-
! Author
| {{{Author|}}}
|-
! Year
| {{{Year|}}}
|}
[[Category:Books]]
</includeonly>

2. The Input Interface (Form:Book)

The form provides a user-friendly way to fill out the template without touching wikitext. It also enables autocompletion from existing Cargo data.

Path: Form:Book

{{{standard input|itemname|label=Book Page Title}}}

{{{for template|Book}}}
{| class="formtable"
! Book Title:
| {{{field|Title|mandatory}}}
|-
! Author:
| {{{field|Author|input type=combobox|cargo table=Books|cargo field=Author}}}
|-
! Publication Year:
| {{{field|Year|input type=number}}}
|}
{{{end template}}}

'''Summary of changes:'''
{{{standard input|summary}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|cancel}}}

3. Activation Steps

After saving the pages above, you MUST perform these steps to activate the database:

  1. Go to Template:Book.
  2. Click the "Create data table" (or "Recreate data") tab at the top.
  3. Click OK to initialize the SQL table.
  4. Go to and add Template:code to ensure the "Edit with form" button appears automatically.

4. Querying the Data

To display the data stored in your "Books" table on any other page, use a Cargo query:

{{#cargo_query:
|tables = Books
|fields = _pageName=Page, Title, Author, Year
|where = Year > 2000
|format = table
|display_columns = Page, Title, Author, Year
}}

Resources

  • [www.mediawiki.org Cargo Storing Documentation]
  • [www.mediawiki.org Page Forms Definition Guide]