Personal tools

Template:DocumentData: Difference between revisions

From GxPlex

Jump to: navigation, search
Auto-populate References section via live #ask instead of static table
Deploy ANG-2026-0011
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
|reference=
|reference=
|validity_area=
|validity_area=
|scopes=
|doc_name=
|doc_name=
|version=
|version=
Line 30: Line 29:
page whose <code>has_document</code> field points here, so newly created references appear
page whose <code>has_document</code> field points here, so newly created references appear
automatically without editing this page — no manual table to keep in sync.
automatically without editing this page — no manual table to keep in sync.
'''Scope(s)''' is not entered by hand. On Document: pages it is the distinct
<code>RefScope</code> values of all References pointing here, stored as a multi-value
<code>DocScopes</code> and shown as e.g. "G ; HM". On Reference: pages, which transclude
their Document, the box shows the stored <code>DocScopes</code> of that Document.
A <code>scopes=</code> parameter in old page sources is ignored. The same #ask appears
twice (for #set and for the box); the query string is identical, so SMW records it as
one query. <code>@annotation</code> marks it as input for stored values, see
[[Help:Semantic MediaWiki|SMW]] query dependencies. Saving a Reference queues a refresh
of its Document (config/GxPlexHooks.php, section 6).
'''Validity area''': one or more area codes separated by <code>;</code> (e.g. <code>EU;GBR</code>).
Each code is an [[:Category:Areas of validity|Area: page]]; <code>DocValidityArea</code> is stored as
links to these pages (Page type, multiple values) and shown as links in the box.
'''Submitted by''' and '''Contributors''': if the field is empty, the values come from the
page history of the Document (<code><nowiki>{{#gplxcreator:}}</nowiki></code> = account that created the page,
<code><nowiki>{{#gplxcontributors:}}</nowiki></code> = every account that edited it). A name links to its user page, or
reads "Anonymous" if there is none. Accounts listed in [[MediaWiki:Gplx-excluded-contributors]]
are left out (config/GxPlexHooks.php, section 8). Values entered in the form always win.


[[Category:Templates]]
[[Category:Templates]]
</noinclude><includeonly>{{#ifeq:{{NAMESPACE}}|Document|{{#set:
</noinclude><includeonly>{{#ifeq:{{NAMESPACE}}|Document|{{#set:
|DocReference={{{reference|}}}
|DocReference={{{reference|}}}
|DocValidityArea={{{validity_area|}}}
|DocValidityArea={{#arraymap:{{{validity_area|}}}|;|x|Area:x|;}}
|DocScopes={{{scopes|}}}
|+sep=;
|DocScopes={{#ask: [[Reference:+]] [[HasDocument::{{FULLPAGENAME}}]] |?RefScope |mainlabel=- |format=plainlist |headers=hide |link=none |sep=; |valuesep=; |limit=500 |searchlabel= |@annotation}}
|+sep=;
|DocName={{{doc_name|}}}
|DocName={{{doc_name|}}}
|DocVersion={{{version|}}}
|DocVersion={{{version|}}}
Line 43: Line 64:
|DocDescription={{{description|}}}
|DocDescription={{{description|}}}
|DocRestricted={{{restricted|}}}
|DocRestricted={{{restricted|}}}
|DocSubmittedBy={{{submitted_by|}}}
|DocSubmittedBy={{#if:{{{submitted_by|}}}|{{{submitted_by|}}}|{{#gplxcreator:plain}}}}
|DocContributors={{{contributors|}}}
|DocContributors={{#if:{{{contributors|}}}|{{{contributors|}}}|{{#gplxcontributors:plain}}}}
|+sep=,
}}}}
}}}}


{{DocumentBox
{{DocumentBox
|doc_page={{#ifeq:{{NAMESPACE}}|Reference|{{#gplxrefdoc:}}}}
|reference={{{reference|}}}
|reference={{{reference|}}}
|validity_area={{{validity_area|}}}
|validity_area={{#arraymap:{{{validity_area|}}}|;|x|[[Area:x|x]]|\s;\s}}
|scopes={{{scopes|}}}
|scopes={{#switch:{{NAMESPACE}}
|Document={{#gplxdistinct:{{#ask: [[Reference:+]] [[HasDocument::{{FULLPAGENAME}}]] |?RefScope |mainlabel=- |format=plainlist |headers=hide |link=none |sep=; |valuesep=; |limit=500 |searchlabel= |@annotation}}}}
|Reference={{#gplxdistinct:{{#ask: [[-HasDocument::{{FULLPAGENAME}}]] |?DocScopes |mainlabel=- |format=plainlist |headers=hide |link=none |sep=; |valuesep=; |searchlabel=}}}}
}}
|doc_name={{{doc_name|}}}
|doc_name={{{doc_name|}}}
|version={{{version|}}}
|version={{{version|}}}
Line 59: Line 85:
|official_link={{{official_link|}}}
|official_link={{{official_link|}}}
|restricted={{{restricted|}}}
|restricted={{{restricted|}}}
|submitted_by={{{submitted_by|}}}
|submitted_by={{#if:{{{submitted_by|}}}|{{{submitted_by|}}}|{{#gplxcreator:}}}}
|contributors={{{contributors|}}}
|contributors={{#if:{{{contributors|}}}|{{{contributors|}}}|{{#gplxcontributors:}}}}
}}
}}
{{#ifeq:{{NAMESPACE}}|Document|
{{#ifeq:{{NAMESPACE}}|Document|
Line 69: Line 95:
| ?RefDocPart = Document part
| ?RefDocPart = Document part
| ?RefLanguage = Language
| ?RefLanguage = Language
| ?RefPreview = Preview
| format = table
| format = table
| class = sortable wikitable smwtable gplx-ref-table
| headers = show
| headers = show
| limit = 500
| limit = 500

Latest revision as of 12:33, 19 November 2026

Data template for Document: pages. Used by Form:Document. Sets the same SMW properties and renders the same

Document information
Reference
Validity area
Scope(s)
Document name
Version / Revision
Status
Document type
Language(s)
Description
Official source —
Restricted access No
Submitted by
Contributors

infobox that the Excel-based XML import produces, so

existing imported pages can be edited through the form without losing data.

Usage

{{DocumentData
|reference=
|validity_area=
|doc_name=
|version=
|status=
|doc_type=
|language=
|description=
|official_link=
|restricted=No
|submitted_by=
|contributors=
}}

Properties are only set on Document: pages themselves (Template check below) — not when a Document: page is transcluded onto a Reference: page via {{:Document:...}}, which would otherwise duplicate Doc* properties onto the Reference: page. The same check gates the "References" section: a live #ask query listing every Reference: page whose has_document field points here, so newly created references appear automatically without editing this page — no manual table to keep in sync.

Scope(s) is not entered by hand. On Document: pages it is the distinct RefScope values of all References pointing here, stored as a multi-value DocScopes and shown as e.g. "G ; HM". On Reference: pages, which transclude their Document, the box shows the stored DocScopes of that Document. A scopes= parameter in old page sources is ignored. The same #ask appears twice (for #set and for the box); the query string is identical, so SMW records it as one query. @annotation marks it as input for stored values, see SMW query dependencies. Saving a Reference queues a refresh of its Document (config/GxPlexHooks.php, section 6).

Validity area: one or more area codes separated by ; (e.g. EU;GBR). Each code is an Area: page; DocValidityArea is stored as links to these pages (Page type, multiple values) and shown as links in the box.

Submitted by and Contributors: if the field is empty, the values come from the page history of the Document ({{#gplxcreator:}} = account that created the page, {{#gplxcontributors:}} = every account that edited it). A name links to its user page, or reads "Anonymous" if there is none. Accounts listed in MediaWiki:Gplx-excluded-contributors are left out (config/GxPlexHooks.php, section 8). Values entered in the form always win.