Hello,
I'm attempting to set up an instance of MediaWiki (version 1.4.x) for
a community site, and I was trying to implement some custom
formatting. I will describe a little more of what I tried further
down the mail, but I have one particular question, so I'll get that
out of the way first:
I want to use an Extension within a template (details of why
below...), and, in particular, to pass in template parameters to the
extension. So the template call is
{{myTemplate|argument1}}
with the code within the template looking something like
<myFirstExt>{{{1}}}</myFirstExt>
but the problem is that I get the string '{{{1}}}' passed in to the
extension, rather that the value entered in the template call,
'argument1' in the exampel.
Sooo, my question is as follows: is there any way to get the value of
the argument into the extension?
To give a little bit of background, basically I want to define a few
extensions, but, to get the formatting that I want, each extension
needs to be aware of what extensions have already been used. I had
kinda assumed that each extension would be invoked in the order in
which they were used in the body of the entry, but it appears that all
instances of each type of extension is processed in turn (I assume
because it uses preg_replace_callback, but I haven't checked that).
So for example, in the following code
== My first heading ==
Introductory text Introductory text Introductory text Introductory text
<myFirstExt>first lot of stuff</myFirstExt>
<mySecondExt>more stuff</mySecondExt>
=== sub-heading ===
<myFirstExt>some sub-stuff</myFirstExt>
the code processing the second <myFirstExt> block is invoked before
the code processing the <mySecondExt> block. So an alternative
question could be, is there any way of getting extensions within a
document processed in order? But I guessed that that was harder.
To get around this, I wanted to try putting Template aliases in the
actual document, with the custom extension code invoked in the
Template definitions. This seemed to get round the ordering, but then
I couldn't do anything with the input parameters, which led to my
first question.
If it's not straight-forward to pass in template parameters to the
extension, would anyone be able to give me some pointers on where I
could try modifying the underlying code to get it to do so? It seems
to me that this could be a useful thing for people to be able to do,
but that may just be because of my relative inexperience in this
stuff, so all feedback would be appreciated.
As a matter of interest, and from a novice's point of view, I found
both of these behaviours counter-intuitive, but I don't know whether
that's just inexperience with PHP and MediaWiki.
Thanks very much in advance for your help. Yours,
Stephen.