Footer Navigation Bar

__FO__ This is a fairly ugly (imho) solution to a problem I had when working on my personal wiki. Even though it's ugly, it happens to work perfectly for me. I hope it'll help other people with the same problems I had.

Situation
I have a wiki in which I have created about eighty namespaces in order to further categorize my information (yeah, I'm anal). I created a fairly rigorous and uniform system of tables for navigating the wiki. They hang out in templates and are included from each file.
Problems
1. I like having printable versions of my wiki. My printable documents (consisting of {{Namespace:Document 1}} {{Namespace:Document 2}}-type stuff end up including the templates that the original documents call, of course, thus providing me with several dozen copies of the same navigation bar. For someone who has to print out several dozen documents every couple weeks in order to put his mind at ease, this waste of ink and paper is horrible.
2. I hate starting a new document and having to remember to type {{All Namespaces Navigation Bar}}{{This Namespace Navigation Bar}}{{Corresponding and Cross-indexed Articles Navigation Bar}} et cetera just to get the document navigable, let alone remembering to spell everything properly, put terms in the proper order, et cetera. It kills productivity.
C. Did I mention that I have a great deal of difficulty with creating complex patterns and then having to remember them?
Solution
What I have done here, which is an ugly hack by someone who is a complete n00b with php. Although I used this for navigation bars, there's no reason this couldn't be done with any other template. Hopefully I don't look like an idiot by posting something that's easily mimicked through some less complex/"factory" option. If I am, sorry for wasting your time.

If not, then I hope that this will help people who are just as lazy and inexperienced as I am. It's greatly boosted my productivity as well as the attractiveness of my site.

Installing the Hack

edit

This is simple -- first, you create the information that you want to be reproduced on every page. Second, you edit the appropriate skin's .php and insert some code at the appropriate place.

Step 1: Create Reproducible Data

edit

First, create the information you want in each page.

What I did was the following (just as an example):

Template:Table Header -- this begins a table.

{| class="toccolours" style="margin: 0 2em 0 2em;"

Template:Root Navigation Bar -- this is text that appears on every page.

|-
| style="background:#000000" align="center" width="550px"| <b><font color="white">Namespaces</font></b> 
|-
| align="center" style="font-size: 75%" | [[Namespace_1:Main Page|Namespace 1]] | [[Namespace_2:Main Page|Namespace 2]] | [[Namespace_3:Main Page|Namespace 3]] 

Template:Namespace_1 Navigation Bar -- this is text that appears only on the appropriate namespace.

|-
| style="background:#000000" align="center" width="550px"| <b><font color="white">Namespace_1</font></b> 
|-
| align="center" style="font-size: 75%" | [[Namespace_1:Main Page|Main Page]]  | [[Namespace_1:Another Page|Another Page]] | [[Namespace_1:A Third Page|A Third Page]]

Template:Table Footer -- this ends a table.

|-
|}

If you're wondering why I have "Table Header" and "Table Footer," it's so that the end result of this creates one large table instead of two tables joined together, which imho looks ugly. You could prepend the text from Table Header to the Root Navigation Bar and append the text from Table Footer to every namespace's navigation bar, but if you go to three or more levels of organization (which I'm doing), then you'll have to change everything. Similar story about if you want to change the style of your table, et cetera et cetera. Anyone reading this is likely to be more advanced in template-fu than I am, though, so... yeah. If you change a little or a lot, I doubt it will break anything.

Step 2: Edit skins/MonoBook.php

edit

FIND:

<!-- start content -->
<?php $this->html('bodytext') ?>

AFTER THAT, INSERT:

                <?php
                global  $wgParser, $wgUser, $wgTitle;
                $parserOptions = ParserOptions::newFromUser( $wgUser );
                $parser = & new Parser();
                $inputText="<center><br><br>{{Table Header}}{{Root Navigation Bar}}
                {{{{NAMESPACE}} Navigation Bar}}
                {{Table Footer}}";
                $output= & $parser->parse($inputText,$wgTitle,$parserOptions);
                echo $output->getText();
                ?>

That snippet is a revised snippet stolen from the "Extension FAQ." The Parser stuff is needed because if you just put in the {{Table Header}} stuff, then you'll be staring in irritation at a wiki page with curly bracketed text at the bottom. Which doesn't help much. This calls the Parser (properly, I hope) which will wikify any stuff put in the $inputText variable.

Again, I should clarify that I have absolutely zero knowledge of php or any other programming language. I just hacked this together to solve a problem I had and then realized that other people might have the same problem. There might be a much cleaner way to do this -- there might be a lot of code here that is completely unneeded.

Step 3: Test

edit

Go to any page on your wiki, and you should see the wiki at least trying to insert the template. If it b0rks your wiki, my name is George and I live on Pennsylvania Avenue in DC. Come visit, I dare you.

I really hope this helps someone.

Notes

edit

There are some other places to put this, of course. The location I have given is right beneath the article's text, in the right segment of the wiki (at least with MonoBook). I also tried putting it at the very bottom with the copyright notices and such, but it looked like hell. I'd imagine most people would rather arrive at an article and read text instead of a navigation menu, which is why I didn't provide interesting locations at the top of the article text. Of course, if that's your thing, I suppose that moving the code up one line when you insert it would accomplish that goal.

Another neat idea I pondered briefly would be using this to create intelligent menus in the left section (ie, with the Toolbox and Navigation things). However, since my menus are very large, this was never an option. It also seems a bit unfriendly to me.

I think that covers it.

A simpler solution

edit

A simpler solution would just be to create a CSS class. In the template, create a class called "noprint".

<div class="noprint">
blah blah blah
</div>

Then in skin/common/wikiprintable.css add the following:

.noprint {
display: none;
}
What the hell does that have to do with this hack?

FYI: I didn't post the above, but I think I know where they are going with it. You can print your documents without the navigation bars showing...hence saving paper, the original idea behind your motiviation.