Topic on Extension talk:JSWikiGantt

Not compatible with templates?

2
Michael Chidester (talkcontribs)

I'm trying to set up templates that can automatically generate gantt charts based on inputs, but there seem to be fundamental compatibility problems.

  • Template variables are not accepted as inputs, and seem to cause "Fatal error: Call to a member function getElementsByTagName() on a non-object"
  • Magic words and parser functions cause the same phenomenon
  • Templates containing task entries (like one template per task declaration) are discarded
  • My only success has been including the entire block of code in a single template, including the opening and closing tags, with all hard-coded values; this transcludes normally

My ultimate objective is get this extension running in a Semantic Mediawiki environment, to generate Gantt charts based on the outputs of #ask queries, but that means each line of the chart needs to be packaged as an individual template, and the values delivered to it as template variables. There was once an extension that did this automatically, but it has been mothballed.

What I need to be able to do is something like this:

Template:EQDD contributor tracker gantt chart/row

<includeonly>
  <task>
    <pID>{{#vardefineecho: taskid | {{#expr: {{#var:taskid}} + 10 }} }}</pID>
    <pName>{{{2|}}}</pName>
    <pStart>{{#dateformat: {{{3|}}} |ISO 8601}}</pStart>
    <pEnd>{{#dateformat: {{{4|}}} |ISO 8601}}</pEnd>
    <pColor>36b</pColor>
    <pLink>{{canonicalurl: {{{1|}}} }}</pLink>
   </task>
</includeonly>

Please advise.

MW 1.25.2
PHP 5.5.38
MySQL 5.7.20-log
SMW 2.5.6

~ Michael Chidester (Contact) 20:07, 24 October 2018 (UTC)

Nux (talkcontribs)

You can use something like this to load external XML with tasks:

<jsgantt loadxml="1">
<a href="http://localhost/wiki-jsgantt/job_cal.xml">link</a>
</jsgantt>

You can load an article like this too:

<jsgantt loadxml="1">
<a href="http://localhost/wiki/index.php/Loading_jsgantt/xml?action=raw">link</a>
</jsgantt>

The problem is that when `action=raw` is used then templates will not be transcluded. So only static xml would work. And when `action=render` is used then everything is rendered which includes `jsgantt` tags. You could just have tasks in some other root tag... But then mediawiki will escape XML and it will look like this:

<p>&lt;root&gt;
&lt;task&gt;
&lt;pID&gt;20&lt;/pID&gt;
&lt;pName&gt;Nux&lt;/pName&gt;
&lt;pStart&gt;2011-06-10&lt;/pStart&gt;
&lt;pEnd&gt;2011-06-14&lt;/pEnd&gt;
&lt;pColor&gt;00cc00&lt;/pColor&gt;
&lt;pRes&gt;Time off&lt;/pRes&gt;
&lt;/task&gt;
&lt;/root&gt;
</p>

So... Basically you have to figure out a way to generate XML with your tasks and then loading it with jsgantt will work. Just not sure if it's possible to generate XML with templates. With Lua maybe?

Reply to "Not compatible with templates?"