user1250923
user1250923

Reputation:

Different links in MediaWiki

I am using MediaWiki version 1.18.2, I know that if I want my links to open in new tab/window I have to set up

$wgExternalLinkTarget = '_blank';

in LocalSettings.php

I am creating the links like this

[http://www.google.com/ google]

is there a way that I can make some links open in the same tab/window and others in new tab/window with the same settings in LocalSettings.php?

Upvotes: 1

Views: 739

Answers (2)

MidnightLightning
MidnightLightning

Reputation: 6928

Mediawiki allows you to wrap html tags around links; you can set the default to not open a new tab/window, and for those you do want to have in a new window, wrap in a different class:

<span class="new-win">[http://google.com google]</span>

Then you can use JavaScript to make all the "new-win"-wrapped links open a new window; add this to your Common.js script:

jQuery( document ).ready( function( $ ) { 
  $(".new-win a").click(function(event) {
    event.preventDefault(); // Keep from following standard href of link
    new_win = window.open($(this).attr('href'), 'offsite_popup') // Pop up a window to that URL
    if (window.focus) { new_win.focus() } // Give it focus if possible
  });
});

EDIT: Modified for user's intent

Upvotes: 1

Tgr
Tgr

Reputation: 28160

You could easily write an extension doing that by using the LinkerMakeExternalLink hook.

Upvotes: 0

Related Questions