Difference between revisions of "MediaWiki/archive/customizing/new navbox"
m (→{{hide|navbar}}: changed template name) |
m (Woozle moved page add a new navigation box to MediaWiki to MediaWiki/archive/customizing/new navbox without leaving a redirect: probably quite obsolete) |
||
(9 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | = | + | =add a new navigation box to MediaWiki= |
− | |||
− | |||
==Overview== | ==Overview== | ||
"Navigation Box" refers to either of the two sets of links in the control bar -- displayed at left under the wiki logo in MonoBook, possibly elsewhere with other skins. Normally there are three: "navigation", "search", and "toolbox". These can easily be modified extensively, but I wanted to add another one for links back to the "main site" (of which the wiki was just a part). Unfortunately, it looks like this has to be done separately for each skin (I guess the thinking is that a given skin might want to give each box special treatment, though it would be nice if there were a way to set up default handling for all boxes). Looking just at MonoBook.php, this code produces the box normally labeled "navigation": | "Navigation Box" refers to either of the two sets of links in the control bar -- displayed at left under the wiki logo in MonoBook, possibly elsewhere with other skins. Normally there are three: "navigation", "search", and "toolbox". These can easily be modified extensively, but I wanted to add another one for links back to the "main site" (of which the wiki was just a part). Unfortunately, it looks like this has to be done separately for each skin (I guess the thinking is that a given skin might want to give each box special treatment, though it would be nice if there were a way to set up default handling for all boxes). Looking just at MonoBook.php, this code produces the box normally labeled "navigation": |
Latest revision as of 23:22, 14 December 2017
Overview
"Navigation Box" refers to either of the two sets of links in the control bar -- displayed at left under the wiki logo in MonoBook, possibly elsewhere with other skins. Normally there are three: "navigation", "search", and "toolbox". These can easily be modified extensively, but I wanted to add another one for links back to the "main site" (of which the wiki was just a part). Unfortunately, it looks like this has to be done separately for each skin (I guess the thinking is that a given skin might want to give each box special treatment, though it would be nice if there were a way to set up default handling for all boxes). Looking just at MonoBook.php, this code produces the box normally labeled "navigation":
<h5> <?php $this->msg('navigation') ?>
<div class="pBody"> <ul> <?php foreach($this->data['navigation_urls'] as $navlink) { ?> <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> </li> <?php } ?>
Immediately after that, I added the following:
<!-- 2005-06-16 Woozle customizations --> <h5> <?php $this->msg('backlinks') ?>
<div class="pBody"> <ul> <?php foreach($this->data['backlink_urls'] as $navlink) { ?> <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> </li> <?php } ?>
<!-- end custom code -->
Reloading the page after this change produced no immediate results, but some time later a cache must have expired and some error messages appeared under the "navigation" box. After that, I defined MediaWiki:backlinks to contain "vbz links", and a box labeled "vbz links" faithfully appeared (with an error message in it). Next, I added the following code to LocalSettings.php (near the end, just before the "?>"):
## 2005-06-16 Woozle customizations: define "backlinks" and "backlink_urls" for custom skin code: $wgMainsiteLinks = array ( array( 'text'=>'sitelink1','href'=>'sitelink1-url' ), array( 'text'=>'sitelink2','href'=>'sitelink2-url' ), array( 'text'=>'sitelink3','href'=>'sitelink3-url' ), array( 'text'=>'sitelink4','href'=>'sitelink4-url' ), array( 'text'=>'sitelink5','href'=>'sitelink5-url' ), array( 'text'=>'sitelink6','href'=>'sitelink6-url' ), array( 'text'=>'sitelink7','href'=>'sitelink7-url' ), array( 'text'=>'sitelink8','href'=>'sitelink8-url' ), array( 'text'=>'sitelink9','href'=>'sitelink9-url' ), ); ## end Woozle customization
(Note: I discovered by accident that either "_url" or "-url" will work as a prefix, but they're not equivalent; if you change the value and the control bar doesn't appear to change, make sure you're not confusing them with each other.) Then I modified SkinTemplate.php (the top and bottom lines were there already):
$tpl->set( 'navigation_urls', $this->buildNavigationUrls() ); $tpl->set( 'mainsite_urls', $this->buildMainsiteUrls() ); // # 2005-06-16 Woozle customization $tpl->set( 'nav_urls', $this->buildNavUrls() );
...and finally MonoBook.php (inserted area as indicated by comments):
<h5> <?php $this->msg('navigation')?>
<div class="pBody"> <ul><?php foreach($this->data['navigation_urls'] as $navlink) { ?> <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> <a href="<?php echo htmlspecialchars($navlink['href'])?>"><?php echo htmlspecialchars($navlink['text']) ?></a> </li>
<?php } ?>
<!-- 2005-06-16 Woozle customizations --> <h5> <?php $this->msg('backlinks') ?>
<div class="pBody"> <ul> <?php foreach($this->data['mainsite_urls'] as $navlink) { ?> <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> </li>
<?php } ?>
I think that's all the code mods I made. Once those are done, all that's left is to modify MediaWiki:Sitelink1, MediaWiki:Sitelink1-url, and so on. To make a line disappear (without removing it from the custom code), set the displayed text to "-".