tags:

views:

21

answers:

1

Hello all,

I'm setting up a bunch of different language mediawiki's on one codebase. So far most of it is working, but I want to use a main page that looks different than the rest of the pages. To do this I originally just added some css rules that only applied to the main_page class:

body .page-Main_Page { <rules> }

The problem is that in other languages the main page is called differently (and the class changes accordingly), so I either have to add css rules for all possible main page titles (not gonna happen) or do a check inside the skin that adds a class to the body if the current page is the main page.

Unfortunately, there's no way to check that. Most solutions I've googled are based on either 'Main Page' or setting your own title. I want the skin to detect the title automatically.

The only solution I´ve thought of so far is take mediawiki´s variable for the main page url and compare it to the current page title:

$mainurl = $this->data['nav_urls']['mainpage']['href'];
$ismain = $this->data['thispage'] == substr($mainurl,'6');

(the ['href'] starts with /wiki/, hence the offset of 6)

and later

<body class="<?php echo ($ismain ? 'mainpage' : ''); ?>">    

(and some more classes of course, but you get the idea)

But this gives me another problem. In spanish, the page is called Página Principal. The data['thispage'] has no problems with that, but the ['href'] is saved as /wiki/P%C3%A1gina_Principal

So... can anyone either tell me how to 1. lookup the translation for 'Main Page' in the language that is currently used OR 2. convert P%C3%A1gina_Principal into Página Principal (and the like for other languages) OR 3. show me another way to check if I'm on the main page?

+3  A: 

Haha omg, it was so simple.

$this->data['skin']->mTitle->mUrlform == $mainurl;

Well that proves once again that typing out your problem to someone else can sometimes give you just the insight you needed.. :P

Litso
@Litso - yep, I've been there. Often after I post a question the answer just "appears". Great you've posted the answer as well, thanks. (Don't forget to accept it.)
Mark Robinson
thanks for the reminder :D
Litso