Template:MermaidRelationship: Difference between revisions

From OODA WIKI
Jump to navigation Jump to search
AdminIsidore (talk | contribs)
No edit summary
AdminIsidore (talk | contribs)
No edit summary
Line 1: Line 1:
<includeonly>{{#ask:
<includeonly>{{#if:{{{2|}}}
|[[{{PAGENAME}}]]
  |{{PAGENAMEE:{{{1}}}}}["{{#titleparts:{{{1}}}|2}}"] --> {{PAGENAMEE:{{{2}}}}}["{{#titleparts:{{{2}}}|2}}"]
  |?Connects to=
}}</includeonly><noinclude>
This template formats a single line for a Mermaid graph.
* '''{{{1}}}''' should be the source page (subject).
* '''{{{2}}}''' should be the destination page (object).
It creates a line like: Concept:Node_A["Node A"] --> Concept:Node_B["Node B"]
</noinclude>
```**Explanation of the fix:**
*  This template now requires two parameters, `{{{1}}}` (the source) and `{{{2}}}` (the destination).
*  `{{PAGENAMEE:...}}` creates a valid ID for Mermaid (e.g., `Concept:Node_A`).
*  `{{#titleparts:...|2}}` creates a clean label for the node, stripping the "Concept:" prefix (e.g., `Node A`).
 
---
 
### Step 2: Fix the Graph Page Query
 
Now, we'll update the query to feed the corrected template the two parameters it now expects.
 
**Edit Page:** `Project:Mermaid_Graph_Test`
 
**Replace the entire content of the page with this:**
 
```wikitext
This page tests the dynamic generation of a Mermaid graph from Semantic MediaWiki data.
 
{{#mermaid:
graph TD;
{{#ask:
[[Category:Graph Example]]
[[Connects to::+]]
|? <!-- This becomes parameter {{{1}}} for the template -->
  |?Connects to <!-- This becomes parameter {{{2}}} for the template -->
  |format=template
  |format=template
  |template=MermaidRelationship/Line
  |template=MermaidRelationship
  |link=none
  |link=none
  |sep=
  |sep=
}}</includeonly><noinclude>
}}
This is a wrapper template for generating Mermaid graph relationships. It is intended to be used on the pages that are the source of the connections.
}}
Do not call it directly in a mermaid parser function.
</noinclude>

Revision as of 18:42, 29 August 2025

This template formats a single line for a Mermaid graph.

  • {{{1}}} should be the source page (subject).
  • {{{2}}} should be the destination page (object).

It creates a line like: Concept:Node_A["Node A"] --> Concept:Node_B["Node B"]

```**Explanation of the fix:**

  • This template now requires two parameters, `{{{1}}}` (the source) and `{{{2}}}` (the destination).
  • `...` creates a valid ID for Mermaid (e.g., `Concept:Node_A`).
  • `...` creates a clean label for the node, stripping the "Concept:" prefix (e.g., `Node A`).

---

      1. Step 2: Fix the Graph Page Query

Now, we'll update the query to feed the corrected template the two parameters it now expects.

    • Edit Page:** `Project:Mermaid_Graph_Test`
    • Replace the entire content of the page with this:**

```wikitext This page tests the dynamic generation of a Mermaid graph from Semantic MediaWiki data.