[Mediawiki-l] getting namespace of current page in php

Matt Hucke hucke at cynico.net
Wed Oct 4 00:48:24 UTC 2006


I'd like to modify the links in the standard navigation portlets in
the standard page layout, as seen in skins/MonoBook.php and similar.
These links need to change based upon the namespace of the currently
displayed page.

Here is the relevant portion:

a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
    ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"
<?php ?>title="<?php $this->msg('mainpage') ?>"></a>

For " $this->data['nav_urls']['mainpage']['href']", I'd like to prefix it
with the current namespace; something like:

    href="<?php echo htmlspecialchars(
            $something->getNameSpacePrefix() . ':' .     # ????

Our site uses namespaces for language switching.  The logo and main page links
on a page in the DE or PT namespace should ideally link to DE:Main_Page or
PT:Main_Page, respectively.  (These other Main_Pages are actually
redirects to articles like "PT:Página Inicial",so it isn't necessary
to get the localised title when linking)


(wiki site is http://www.novaroma.org/nr/)

hucke at cynico.net

"What is the difference? What indeed is the point? ...The
clarity is devastating. But where is the ambiguity? It's
over there, in a box." -- J. Cleese

More information about the MediaWiki-l mailing list