Hi,
I am in the process of creating an extension tag to suit my project requirements. Actually, we have an xml structure which should be processed using Templates inside this extension implementation. Briefly, I woud like to create pieces of a table using different templates.
Example :
If I need a HTML Table with header "Agents" as follows : Agents Agent1 Agent2 Agent3 . . AgentN
For the above table with 1 column and N rows, the wiki text would look something like :
{| border="1" cellpadding="2" ! Agents |- | Agent1 |- | Agent2 |- | Agent3 |- . . | AgentN |- |}
In my case, I dont know the value of "N". This depends on the values from XML. So, I would like to create a template to process each row based on the input from XML iteratively for N rows..
Wikitext for this template would look something like :
| {{{parameterName}}} |-
where parameterName's value could be : Agent1, Agent2, ....AgentN.
But the current mediawiki parser wont parse the above template properly because it expects complete table syntax not pieces of it. I am wondering if there is any workaround or way out to achieve this ?
Please let me know if this is not the right place to post questions about mediawiki.
Suresh
On Tue, 8 Mar 2005 13:30:31 -0500, suresh.k.kadirvel@gsk.com
But the current mediawiki parser wont parse the above template properly because it expects complete table syntax not pieces of it. I am wondering if there is any workaround or way out to achieve this ?
I don't think this is true. Certainly, viewing the template *by itself* won't produce anything useful, but I'm pretty sure the inclusion mechanism just shoves the text together, and that the "infoboxes" on en.wikipedia use exactly this kind of trick to allow optional rows etc.
I tested, and after creating a template (let's call it [[Template:Table row]]) with the 2 lines: |--- | {{{text}}}
I could create a page with something like this: {| border="1" ! Heading {{Table row|text=This is the first row}} {{Table row|text=This is the second row}} |}
And it would work fine.
With respect to your extension, note that the text returned by an extension is treated as *raw output* (i.e. HTML), *not wiki markup*. So to use the wiki table syntax in an extension, you'll have to call Parser::parse() on it directly.
According to a quick search of the list archives, Christof Damian wrote a function like this: function renderer($input) { global $wgTitle,$wgParser,$wgUser; $output = $wgParser->parse($cal->getCurrentMonthView(), $wgTitle, ParserOptions::newFromUser($wgUser)); return $o->getText(); }
While FxParlant (based on my untested assumptions) got this to work: global [...] $wgUser,$wgParser,$parserOptions,$wgTitle, $wgOut,$wgLinkCache; [ ... ] $wgLinkCache->suspend(); $parsed = $wgParser->parse( $mytext, $wgTitle, $wgOut->mParserOptions, true); $output .= $parsed->getText(); return $output;
It does look like some "quick" way of doing this within extensions would be nice, but it seems to be doable anyhow.
Please let me know if this is not the right place to post questions about mediawiki.
Well, mediawiki-l is preferred for topics unrelated to core development or the Wikimedia-family of websites, but I think more or less the same people read both anyway. I expect someone will complain they like to have them filtered seperately, but personally I shove them both in the same GMail 'label'.
wikitech-l@lists.wikimedia.org