[Mediawiki-l] Linking to "parent page"
Rowan Collins
rowan.collins at gmail.com
Tue Mar 1 17:32:31 UTC 2005
On Tue, 01 Mar 2005 01:16:07 +0100, Dorthe Luebbert
<luebbert at globalpark.de> wrote:
> Hi,
>
> is it possible to link to the parent page automatically? E.g. using a
> special variable ?
MediaWiki doesn't really have a concept of "parent page" - it's not a
hierarchical structure. That said, there is limited support for a
"sub-pages" system, which is disabled by default for the main
namespace to encourage a "web" rather than "tree" structure, which was
deemed to be much more useful (specifically, in the context of an
encyclopedia, but the same arguments apply to many other projects
too). And it does indeed provide links to the "parents" of pages. But
it is based entirely on the names of the pages - [[Section 1/Page 1]]
would be a "sub-page" of [[Section 1]], and [[Section 1/Page
1/Supplement]] would be a "sub-page" of that. You might find that
rather limiting and ugly - or maybe it would be exactly what you were
after.
I couldn't find any very good documentation on this, but
DefaultSettings.php conatins the following:
/** Which namespaces should support subpages?
* See Language.php for a list of namespaces.
*/
$wgNamespacesWithSubpages = array( -1 => 0, 0 => 0, 1 => 1,
2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1, 8 => 0, 9 => 1, 10
=> 0, 11 => 1);
So to enable sub-pages in the main namespace, you would add something
like the following to your LocalSettings.php (setting namespace 0 to
'1' to represent 'yes, this one has sub-pages'). Pages with a "/" in
their names would then be interpretted as though they were a sub-page
of something else.
$wgNamespacesWithSubpages = array( -1 => 0, 0 => 1, 1 => 1,
2 => 1, 3 => 1, 4 => 0, 5 => 1, 6 => 0, 7 => 1, 8 => 0, 9 => 1, 10
=> 0, 11 => 1);
The only effect I can think of other than automatically linking
parents is that links like [[/foo]] are interpretted as though you'd
said [[<current page>/foo]]; and I think somebody may have implemented
extra tricks like [[../foo]] meaning [[<parent of this>/foo]], but
that may not be in mainstream releases yet (or ever).
Depending on the exact effect you're aiming for, you might also be
able to do something with categories, or just have a template to make
a consistent-looking link at the top of each page by doing something
like {{parentlink|parent=Home}}
--
Rowan Collins BSc
[IMSoP]
More information about the MediaWiki-l
mailing list