Saturday, April 19, 2014
   
Text Size
Login

Change the login link in MediaWiki

As usual I have searched the WWW but I obviously don't how to use Google because I couldn't find an answer. My situation is this:
  • We have an internal wiki knowledge base using MediaWiki version 1.14.
  • Some articles are available for public, some are restricted to staff and different localgroups.
  • When users click on the 'Login' link, we want the system to automatically prompt them for their username/password. (Kerberos authenticated, as opposed to NTLM authenticated).
  • Note: This article is displaying how to change the link and not how to setup these authentication methods.


Open your skin file /skins/.php. Look for and change the following lines:

  1.  <div class="portlet" id="p-personal"> 
  2.            <h5><?php $this->msg('personaltools') ?></h5> 
  3.            <div class="pBody"> 
  4.                 <ul> 
  5.  <?php                foreach($this->data['personal_urls'] as $key => $item) { ?> 
  6.                      <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php 
  7.                           if ($item['active']) { ?> class="active"<?php } ?>><a href="/<?php 
  8.                      echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php 
  9.                      if(!empty($item['class'])) { ?> class="<?php 
  10.                      echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php 
  11.                      echo htmlspecialchars($item['text']) ?></a></li> 
  12.  <?php               } ?> 
  13.                 </ul> 
  14.            </div> 
  15.       </div> 
To

  1.  <div class="portlet" id="p-personal"> 
  2.            <h5><?php $this->msg('personaltools') ?></h5> 
  3.            <div class="pBody"> 
  4.                 <ul> 
  5.  <?php               foreach($this->data['personal_urls'] as $key => $item) { ?> 
  6.                           if (($key!="login")&&($key!="logout")&&($key!="anonlogin")) { 
  7.                                <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php 
  8.                                if ($item['active']) { ?> class="active"<?php } ?>><a href="/<?php 
  9.                                echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php 
  10.                                if(!empty($item['class'])) { ?> class="<?php 
  11.                                     echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php 
  12.                                echo htmlspecialchars($item['text']) ?></a></li> 
  13.  <?php                    } 
  14.                      }  
  15.                      if($this->data['loggedin']==1) { 
  16.                           echo '<li id="pt-logout"><a href="/index.php?title=Special:Userlogout&returnto=Special:MainPage" title="Log Out">Log out</a></li>'
  17.                      } else { 
  18.                           echo '<li id="pt-login"><a href="/wiki/Special:UserLogin?returnto='.trim($_GET['title']).'" title="You are encouraged to log in; however, it is not mandatory [alt-o]" accesskey="o">Log in</a></li>'
  19.                      } ?> 
  20.                 </ul> 
  21.            </div> 
  22.       </div> 
What does this do?
  • Excludes displaying system login, anonymous login or logout links in personal toolbar
  • Add a list item linking to your own login page (in this example the default one as ours is Kerberos_Login) with login or logout link.
Add Comment

Name:

Email:

Website:

Message:


Latest Posts

  • 301 Redirect using htaccess file

    • Tue 15-Apr-14
      Further suggestion:
      RewriteRule ^(.*/)?assets/s 2dmain.html\?/( .*/)? $2 [R=301,L]
      Webmaster  
    • Thu 10-Apr-14
      Playing with some RegEx testers
      RewriteRule ^(.*\?/)?(?:$|( .+?)(?:(\.[^.]$ )|$)) $2 [R=301,L] ...
      Webmaster  
    • Wed 09-Apr-14
      I tried to redirect links from my old site to my new site, based on what I read in this thread. The old ...
      pelle
  • JComments 2.3.0 with ReCaptcha in Joomla 2.5.x

    • Fri 28-Mar-14
      You are a rockstar mate! thanks. Followed the steps listed and it worked! If only all tutorials were ...
      Kman
  • K2 Items disappear

    • Thu 03-Apr-14
      The fix works great, but the problem is occurring a couple of times a day. Any idea how to fix ...
      Larry C.