Difference between revisions of "MediaWiki/archive/customizing/new navbox"
(changed <pre> stuff to indented) |
|||
Line 1: | Line 1: | ||
− | + | {{mediawiki article|Add a New Navigation Box|to MediaWiki}}{{neededit}} | |
− | + | ||
− | + | "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, | + | <h5> |
− | possibly elsewhere with other skins. Normally there are three: | + | <?php $this->msg('navigation') ?> |
− | "navigation", "search", and "toolbox". These can easily be modified | + | </h5> |
− | extensively, but I wanted to add another one for links back to the | + | <div class="pBody"> |
− | "main site" (of which the wiki was just a part). | + | <ul> |
− | Unfortunately, it looks like this has to be done separately for each | + | <?php |
− | skin (I guess the thinking is that a given skin might want to give each | + | foreach($this->data['navigation_urls'] as $navlink) { ?> |
− | box special treatment, though it would be nice if there were a way to | + | <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> |
− | set up default handling for all boxes). Looking just at MonoBook.php, | + | <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> |
− | this code produces the box normally labeled "navigation": | + | </li> |
− | + | <?php } | |
− | ?></h5> | + | ?> |
− | foreach($this->data['navigation_urls'] as $navlink) { ?> | + | </ul> |
− | id="<?php echo htmlspecialchars($navlink['id']) ?>"> | + | </div> |
− | href="<?php echo htmlspecialchars($navlink['href']) | ||
− | ?>"><?php echo htmlspecialchars($navlink['text']) | ||
− | ?></a> | ||
− | |||
Immediately after that, I added the following: | Immediately after that, I added the following: | ||
− | + | <!-- 2005-06-16 Woozle customizations --> | |
− | + | <h5> | |
− | $this->msg('backlinks') ?></h5> | + | <?php $this->msg('backlinks') ?> |
− | + | </h5> | |
− | $navlink) { ?> | + | <div class="pBody"> |
− | htmlspecialchars($navlink['id']) ?>"> | + | <ul> |
− | htmlspecialchars($navlink['href']) ?>"><?php echo | + | <?php foreach($this->data['backlink_urls'] as $navlink) { ?> |
− | htmlspecialchars($navlink['text']) ?></a> | + | <li id="<?php echo |
− | ?> </ul> </div> | + | htmlspecialchars($navlink['id']) ?>"> |
− | + | <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> | |
− | + | </li> | |
− | Reloading the page after this change produced no immediate results, but | + | <?php } ?> |
− | some time later a cache must have expired and some error messages | + | </ul> |
− | appeared under the "navigation" box. After that, I defined | + | </div> |
− | [[MediaWiki:backlinks]] to contain "vbz links", and a box labeled "vbz | + | <!-- end custom code --> |
− | links" faithfully appeared (with an error message in it). | + | |
− | Next, I added the following code to LocalSettings.php (near the end, | + | 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 "?>"): |
− | just before the "?>"): | + | |
− | + | ## 2005-06-16 Woozle customizations: define "backlinks" and "backlink_urls" for custom skin code: | |
− | ## 2005-06-16 Woozle customizations: define "backlinks" and | + | $wgMainsiteLinks = array ( |
− | "backlink_urls" for custom skin code: | + | array( 'text'=>'sitelink1','href'=>'sitelink1-url' ), |
− | $wgMainsiteLinks = array ( array( | + | array( 'text'=>'sitelink2','href'=>'sitelink2-url' ), |
− | 'text'=>'sitelink1','href'=>'sitelink1-url' ), array( | + | array( 'text'=>'sitelink3','href'=>'sitelink3-url' ), |
− | 'text'=>'sitelink2','href'=>'sitelink2-url' ), array( | + | array( 'text'=>'sitelink4','href'=>'sitelink4-url' ), |
− | 'text'=>'sitelink3','href'=>'sitelink3-url' ), array( | + | array( 'text'=>'sitelink5','href'=>'sitelink5-url' ), |
− | 'text'=>'sitelink4','href'=>'sitelink4-url' ), array( | + | array( 'text'=>'sitelink6','href'=>'sitelink6-url' ), |
− | 'text'=>'sitelink5','href'=>'sitelink5-url' ), array( | + | array( 'text'=>'sitelink7','href'=>'sitelink7-url' ), |
− | 'text'=>'sitelink6','href'=>'sitelink6-url' ), array( | + | array( 'text'=>'sitelink8','href'=>'sitelink8-url' ), |
− | 'text'=>'sitelink7','href'=>'sitelink7-url' ), array( | + | array( 'text'=>'sitelink9','href'=>'sitelink9-url' ), |
− | '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 (MediaWiki)|SkinTemplate.php]] (the top and bottom lines were there already): |
− | ## end Woozle customization | + | $tpl->set( 'navigation_urls', $this->buildNavigationUrls() ); |
− | + | $tpl->set( 'mainsite_urls', $this->buildMainsiteUrls() ); // # 2005-06-16 Woozle customization | |
− | (Note: I discovered by accident that either "_url" or "-url" will work | + | $tpl->set( 'nav_urls', $this->buildNavUrls() ); |
− | as a prefix, but they're not equivalent; if you change the value and | + | ...and finally [[MonoBook.php (MediaWiki)|MonoBook.php]] (inserted area as indicated by comments): |
− | the control bar doesn't appear to change, make sure you're not | + | <h5> |
− | confusing them with each other.) | + | <?php $this->msg('navigation')?> |
− | Then I modified SkinTemplate.php (the top and bottom lines were there | + | </h5> |
− | already): | + | <div class="pBody"> |
− | + | <ul><?php foreach($this->data['navigation_urls'] as $navlink) { ?> | |
− | $tpl->set( 'navigation_urls', $this->buildNavigationUrls() ); | + | <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> |
− | $tpl->set( 'mainsite_urls', $this->buildMainsiteUrls() ); // | + | <a href="<?php echo htmlspecialchars($navlink['href'])?>"><?php echo htmlspecialchars($navlink['text']) ?></a> |
− | 2005-06-16 Woozle customization | + | </li> |
− | $tpl->set( 'nav_urls', $this->buildNavUrls() ); | + | <?php } ?> </ul> |
− | + | </div> | |
− | ...and finally MonoBook.php (inserted area as indicated by comments): | + | <!-- 2005-06-16 Woozle customizations --> |
− | + | <h5> | |
− | ?></h5> | + | <?php $this->msg('backlinks') ?> |
− | foreach($this->data['navigation_urls'] as $navlink) { ?> | + | </h5> |
− | id="<?php echo htmlspecialchars($navlink['id']) ?>"> | + | <div class="pBody"> |
− | href="<?php echo htmlspecialchars($navlink['href']) | + | <ul> <?php foreach($this->data['mainsite_urls'] as $navlink) { ?> |
− | ?>"><?php echo htmlspecialchars($navlink['text']) | + | <li id="<?php echo htmlspecialchars($navlink['id']) ?>"> |
− | ?></a> | + | <a href="<?php echo htmlspecialchars($navlink['href']) ?>"><?php echo htmlspecialchars($navlink['text']) ?></a> |
− | + | </li> | |
− | $this->msg('backlinks') ?></h5> | + | <?php } ?> </ul> |
− | + | </div> | |
− | $navlink) { ?> | + | <!-- end custom code --> |
− | htmlspecialchars($navlink['id']) ?>"> | + | 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 "-". |
− | htmlspecialchars($navlink['href']) | ||
− | ?>"><?php echo htmlspecialchars($navlink['text']) | ||
− | ?></a> | ||
− | <!-- end custom code -- | ||
− | |||
− | 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 | ||
− | "-". |
Revision as of 21:02, 7 December 2005
{{{1}}} |
"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 "-".