ICT:FinalConfig - PLACE
Final Configuration for the Place Entity
Document revision: 2026-02-16 by Mngr
The aim is to create an interface without MediaWiki clutter and well protected to avoid confusing users with unnecessary elements on the page. The Cargo template follows what has been decided in the DBML. It is the implementation of one entity "Place". This entity have a special feature: filling in the address will fill in automativcally the coordinnates and in dashboard you then have a link to openstreetmap. In order to realise this a javascript is an extra. Also, as we use de facto Dark mode, we need to take some measures in order to avoid the system to give error messages with white boxes in this dark environment. Using Vector-2022 as a skin, it is very tricky to try to solves this modifying the Common.css, again a soluiton via Javascript was preferred.
Cargo Table:
Template:Place
<<noinclude>
Place data template
{{#cargo_declare:
_table=Places
|title=String
|code=String
|parent=Page
|type=String
|address=String
|latitude=Float
|longitude=Float
|notes=Text
}}
{{#forminput:form=Place}}
</noinclude>
{{#cargo_store:
title={{{title|}}}
|code={{PAGENAME}}
|parent={{{parent|}}}
|type={{{type|}}}
|address={{{address|}}}
|latitude={{{latitude|}}}
|longitude={{{longitude|}}}
|notes={{{notes|}}}
}}
== {{{title|}}} ==
{{DISPLAYTITLE:{{{title}}}}}
{{#if:{{{parent|}}}|Parent place: [[{{{parent}}}]]}}
Once the template is created don't forget to manually force the creation of the Cargo table. If modifications are done to the table, one needs to manually update the table and then go to the Cargo interface to swap the temporary table to become the official one. Take care what is inside and outside
<noinclude>
Page Form:
Form:Place
<noinclude>
Form for creating and editing Place pages.
</noinclude>
{{{info
|no summary
|no preview
|no minor edit
|no watch
|no footer
}}}
{{{for template|Place}}}
{| class="formtable"
! Title
| {{{field|title|mandatory}}}
|-
! Code
| {{PAGENAME}}
|-
! Parent Place
| {{{field|parent
|label=Parent place
|input type=combobox
|values from namespace=Place
|existing values only
|placeholder=Top level (no parent)
}}}
|-
! Type
| {{{field|type}}}
|-
! Address
| {{{field|address|id=pf-address}}}
|-
! Latitude
| {{{field|latitude|id=pf-latitude}}}
|-
! Longitude
| {{{field|longitude|id=pf-longitude}}}
|-
! Notes
| {{{field|notes|input type=textarea}}}
|}
{{{standard input|save}}}
{{{end template}}}
The first section is important to avoid clutter.
{{{info
|no summary
|no preview
|no minor edit
|no watch
|no footer
}}}
In the display of the Form;Place page one might see
{{{end template}}}
at the bottom. This is not a bug but a side effect too long to explain here.
Dashboard page
Dashboard:Place
= 🗺️ Costa Sano Research PLACE Dashboard =
📖 [[Dashboard:Place/Help|Need Help?]]
{| class="wikitable sortable"
! Code !! Title !! Type !! Parent !! Map
{{#cargo_query:
tables=Places
|fields=_pageName,code,title,type,parent,latitude,longitude
|where=_pageNamespace=3006
|order by=code
|format=template
|template=PlaceRow
|named args=yes
|cache=no
}}
|}
Choose your place code corresponding to above table and respecting the naming conventions.
Take maximum 4 capital letters for the code.
{{#forminput:
form=Place
|namespace=Place
|button text=➕ New place
|returnto=Dashboard:Place
}}
<div style="text-align:right; font-size:90%;">
Last updated: {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} – {{CURRENTTIME}} UTC
</div>
Different measures are taken to deal with caching data in MediaWiki, Cargo and what happens in a browser.
|cache=no
This is needed on the Cargo side to avoid caching and the following puts a new datetime on the page making it different from the previous version with the result that the page is renewed and the cached version is dropped.
<div style="text-align:right; font-size:90%;">
Last updated: {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} – {{CURRENTTIME}} UTC
</div>
This last block should be low enough on the page otherwise the cache flush effect might be missing and manual purge cache needed instead.
The fields address, lattitude and longitude have id - identifiers to be used in the javascript.
The layout of the dashboard makes use of a Template:PlaceRow as described below. It makes the first column of the table clickable to go back to the Form and edit the record.
Row transclusion Template
Template:PlaceRow
<includeonly>
|-
| {{#formlink:form=Place|target={{{_pageName}}}|link text={{{code}}}|returnto=Dashboard:Place}}
| {{{title}}}
| {{#switch:{{{type}}}
|city=🏙️ City
|region=🗺️ Region
|building=🏛️ Building
|site=📍 Site
|#default=📌 {{{type}}}
}}
| {{{parent}}}
| {{#if:{{{latitude}}}{{{longitude}}}|[https://www.openstreetmap.org/?mlat={{{latitude}}}&mlon={{{longitude}}} 🗺️]}}
</includeonly>
Javascript
A javascript is used to fill the coordinnates from the content of the address field. MediaWiki:Common.js
// The form is already present in the DOM, so we can run immediately
$(function() {
const addr = $('input[name="Place[address]"]');
const lat = $('input[name="Place[latitude]"]');
const lon = $('input[name="Place[longitude]"]');
console.log("Address fields found:", addr.length);
if (addr.length === 0) {
console.log("Address field not found");
return;
}
addr.on('change', function() {
console.log("Address changed:", addr.val()); // <— ADD THIS LINE
const q = encodeURIComponent(addr.val());
if (!q) return;
const url = 'https://nominatim.openstreetmap.org/search?format=json&q=' + q;
$.getJSON(url, function(data) {
if (data && data.length > 0) {
lat.val(data[0].lat);
lon.val(data[0].lon);
}
});
});
});
All this creates pages in the namespace Place with the name being the code. The page is a configuration to serve in Page Forms extension. Below is an example of such a page.
{{Place
|title=Berck-sur-Mer
|type=city
|latitude=50.406
|longitude=1.563
|notes=Important location for early Costa Sano history.
}}
As you can see the page as is cannot be used as such and should be read via the dashboard page.