ICT:THE pattern starter kti
Appearance
ICT Starter Kit — Entity Module
This kit provides the four files required to create a new structured data module:
- Template:EntityName
- Form:EntityName
- Dashboard:EntityName
- Template:EntityRow
Replace:
- EntityName → the namespace and form/template name
- TableName → the Cargo table name
- field1, field2… → your actual fields
1. Template:EntityName
<noinclude>
Documentation for EntityName template.
{{#cargo_declare:
_table=TableName
|field1=String
|field2=Text
|field3=Date
|field4=Page
}}
{{#forminput:form=EntityName}}
</noinclude>
{{#cargo_store:
field1={{{field1|}}}
|field2={{{field2|}}}
|field3={{{field3|}}}
|field4={{{field4|}}}
}}
== {{{field1|}}} ==
2. Form:EntityName
<noinclude>
Form for creating and editing EntityName pages.
</noinclude>
{{{info
|no summary
|no preview
|no minor edit
|no watch
|no footer
}}}
{{{for template|EntityName}}}
{| class="formtable"
! Field 1
| {{{field|field1|mandatory}}}
|-
! Field 2
| {{{field|field2|input type=textarea}}}
|-
! Field 3
| {{{field|field3|input type=datepicker}}}
|-
! Field 4
| {{{field|field4|input type=combobox|values from namespace=EntityName}}}
|}
{{{standard input|save}}}
{{{end template}}}
3. Template:EntityRow
<includeonly>
|-
| {{#formlink:form=EntityName
|target={{{_pageName}}}
|link text={{{field1}}}
|returnto=Dashboard:EntityName
}}
| {{{field2}}}
| {{{field3}}}
</includeonly>
4. Dashboard:EntityName
= EntityName Dashboard =
{| class="wikitable sortable"
! Field1 !! Field2 !! Field3
{{#cargo_query:
tables=TableName
|fields=_pageName,field1,field2,field3
|where=_pageNamespace=EntityName
|order by=field1
|format=template
|template=EntityRow
|named args=yes
|cache=no
}}
|}
{{#forminput:
form=EntityName
|namespace=EntityName
|button text=➕ New EntityName
|returnto=Dashboard:EntityName
}}
5. Quick Setup Checklist
- Create Template:EntityName
- Create Form:EntityName
- Create Template:EntityRow
- Create Dashboard:EntityName
- Replace EntityName, TableName, and fields
- Verify:
- Form name = Template name = Namespace
standard input|savepresent#forminput:form=EntityNamein template- Dashboard uses correct namespace
- Row template uses
#formlink
This kit can be reused for any new module (Persons, Locations, Events, Assets…).