[Mediawiki-l] Re: wikipedia page http://en.wikipedia.org/w/index.php/Template:Box_portal_skeleton

Rowan Collins rowan.collins at gmail.com
Sat Nov 12 15:56:41 UTC 2005


On 11/11/05, judi chen <judi_chen at yahoo.com> wrote:
> My problem is that I copied the same code from
> wikipedia to my wiki site.  But the display is
> different.   The page I copied from wikipedia is
> http://en.wikipedia.org/w/index.php/Template:Box_portal_skeleton

Aha, now I can hopefully be a bit less vague about what's going on (at
the price of being more long-winded, to make sure I'm not assuming
knowledge you don't have).

> it seems that on the wikipedia site, some variables
> get  automatically plug into the {{ }} function.

Yes, that is how templates work; see
http://meta.wikimedia.org/wiki/Help:Template Although in some ways
very simple, the template inclusion system is extremely powerful -
almost, some would argue, *too* powerful - and can be combined with
other features in very intricate ways, as seems to be the case here.

> The code associated with it is
>
> {{/box-header|{{{topic}}}
> portal|Portal:{{{topic}}}/Intro|}}
> {{Portal:{{{topic}}}/Intro}}

Actually, no it's not; this may seem picky, but the code is
{{/box-header|{{{topic}}} portal|Portal:{{{topic}}}/Intro|}}
Note that it is all on one line - I'd been assuming that the
linebreaks were just from copying it into the e-mail, but the output
below looks almost as though the first line is being interpretted as a
template with one parameter, "{{{topic", hence the stray "}" at the
end. So perhaps make sure the code is *exactly* as on Wikipedia.

> Template:/box-header}
> portal|Portal:{{{topic}}}/Intro|}}
> {{Portal:{{{topic}}}/Intro}}


The next thing to remember is that templates will not necessarily look
tidy when viewed on their own, since all the variables (numbers or
labels in {{{triple braces}}}) will not be filled in, so the code may
not even be valid (and will probably look different on different
versions of MediaWiki). Only once they have been included on another
page, with the appropriate parameters to fill those variables (as in
"{{box portal skeleton| topic=Chess}}"), will they make any sense.
This is what the "{{Portal:{{{topic}}}/Intro}}" bit is for - once in
use, the "{{{topic}}}" will become, say, "Chess", and this line will
include as a template the page "Portal:Chess/Intro".

In this particular case, the template's authors have also made heavy
use of sub-page features (see
http://meta.wikimedia.org/wiki/Help:Link#Subpage_feature ). The
"Portal:Chess/Intro" above is technically a sub-page, but since it's
full name is given, that doesn't really matter. More importantly, we
have things like "{{/box-header}}", which are also intended as
sub-page links - i.e. they refer not to "Template:/box-header" but to
"<current page>/box-header"; assuming the page we're pasting into is
"Portal:Chess", {{/box-header}} should become equivalent to
{{Portal:Chess/box-header}} .

And now we come to what may be the central issue of your problem:
sub-pages can be turned on and off for each namespace in the wiki, and
are off by default for the main namespace (the one with no specific
prefix). *But*, the "Portal" namespace doesn't actually *exist* in a
default install, so as far as the software is concerned, a page called
"Portal:Chess" is one with that exact name in the main namespace, as
opposed to one called "Chess" in the namespace called "Portal". [See
http://meta.wikimedia.org/wiki/Help:Namespace ]

To emulate the setup of Wikipedia completely, therefore, you need to
first create a namespace called "Portal" (see
http://meta.wikimedia.org/wiki/Help:Custom_namespaces ), and then
enable sub-pages for that namespace, by editting your
LocalSettings.php. You can use your template without doing any of that
though, in an existing namespace which *does* have sub-pages, such as
a Talk: or Project: page (or, indeed, another Template: page).


I hope this explains most of what's going on here, and apologies if it
seems too long-winded; but I thought it better to try and explain the
issues involved rather than just troubleshoot the problem, so that you
can use the features effectively yourself, and overcome other problems
as they arise.

--
Rowan Collins BSc
[IMSoP]



More information about the MediaWiki-l mailing list