Extension:LinkTarget/cs

Toto rozšíření je profesionálně spravováno týmem WikiTeq.
WikiTeq poskytuje oficiální podporu pouze pro verze MediaWiki LTS. Může fungovat s jinými verzemi MediaWiki.
Category:Extensions by WikiTeq/cs Category:GPL licensed extensions/cs
Příručka k rozšířením MediaWiki
LinkTarget
Stav rozšíření: stabilníCategory:Stable extensions/cs
Implementace MyWiki Category:Personalization extensions/cs
Popis Přidá atribut target k zadaným odkazům.
Autoři Ike Hecht (Tosfosdiskuse)
Správci Tým WikiTeq
Nejnovější verze 0.2.0 ()
Zásady kompatibility Pro každé vydání MediaWiki, které je vydáním dlouhodobé podpory, existuje v rozšíření odpovídající větev.
MediaWiki 1.35, 1.39Category:Extensions with manual MediaWiki version
Změny v databázi Ne
Licence GNU General Public License 2.0 nebo novější
Stáhnout Category:Extensions in Wikimedia version control/cs
  • $wgLinkTargetParentClasses
  • $wgLinkTargetDefault
Čtvrtletní stahování 15 (Ranked 81st)
Přeložte rozšíření LinkTarget, používá-li lokalizaci z translatewiki.net
Problémy Otevřené úkoly · Nahlásit chybu
Category:All extensions/cs

Rozšíření LinkTarget umožňuje administrátorům přidat atribut target k interním a externím odkazům. To lze například použít k otevírání interních a externích odkazů v nových oknech.

Toto rozšíření bylo vytvořeno pro WikiWorks.

Instalace

  • Stáhněte soubor/y a vložte je do adresáře pojmenovaného LinkTarget ve vaší složce extensions/.
    Vývojáři a přispěvatelé kódu by si místo toho měli nainstalovat rozšíření from Git pomocí:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LinkTarget
  • Na konec vašeho souboru LocalSettings.php přidejte následující kód:
    wfLoadExtension( 'LinkTarget' );
    $wgLinkTargetParentClasses = ' /*ENTER SOME CLASSES HERE*/ ';
    
  • Yes Dokončeno – Přejděte na stránku Special:Version vaší wiki a zkontrolujte, zda bylo rozšíření úspěšně nainstalováno.

Konfigurace

$wgLinkTargetParentClasses
The descendants of elements of this class will have their target attribute set by the extension. Expects an array with the format:
[
     target => [ classes ],
     target => [ classes ],
      ... 
]
If target is not specified or is invalid, the target will be set to $wgLinkTargetDefault. Note that it is also valid to specify one class as a string, instead of an array of classes.
$wgLinkTargetDefault
The default target for parent classes that do not have a valid target specified.
Can be set to one of the following: _blank, _self, _parent, _top. Defaults to _blank.

Příklady

In LocalSettings.php:

$wgLinkTargetParentClasses = [ 'foo', 'bar' ];

Adds target="_blank" as an attribute to links that are children of an HTML element that belong to either class "foo" or "bar". To use in the wiki:

This is some text with an <span class="foo">[[Internal link]]</span> and also an <span class="bar">[https://www.mediawiki.org External link]</span>.

In that example, both links will open in new windows or tabs.

Example 2: Open specific images in new windows

Using the same LocalSettings as in Example 1, in the wiki use:

<div class="bar">[[File:SomeImage|link=mediawiki.org]]</div>
$wgExternalLinkTarget = '_blank';
$wgLinkTargetParentClasses = [ 'foo', 'bar' ];
$wgLinkTargetDefault = '_self';

In the wiki:

[[This link]] will open in a new window, but not <span class="foo">[[this one]]</span>.

Example 4: Use with extensions

Surround extension parser functions or tags with some code and open any links generated by those extensions in a new window. As an example, we will use the Flickr API extension, with the LocalSettings code from Example 1:

<div class="foo"><flickr>SOMEIMAGEID</flickr></div>

Actually, that extension helpfully already surrounds any code that it generates with a class so really it is sufficient to set LocalSettings as follows:

$wgLinkTargetParentClasses = [ 'flickrapi' ];

This will apply to all Flickr images generated by the extension. When users click on any image, the link will open in a new window or tab.

Advanced

$wgLinkTargetParentClasses = [
     '_top' => [ 'foo' ],
     [ 'bar' ],
     '_parent' => 'baz'
];

Descendants of 'foo' will have target '_top', descendants of 'bar' will have target '_blank' and descendants of 'baz' will have target '_parent'.

Známá omezení

  • The links will not have any special target while viewing the page in "preview" mode.

Související odkazy

Category:Interwiki extensions/cs
Category:All extensions/cs Category:Extensions by WikiTeq/cs Category:Extensions in Wikimedia version control/cs Category:Extensions included in Canasta/cs Category:Extensions included in Miraheze/cs Category:Extensions included in WikiForge/cs Category:Extensions included in semantic::core/cs Category:Extensions with manual MediaWiki version Category:GPL licensed extensions/cs Category:Interwiki extensions/cs Category:OutputPageParserOutput extensions/cs Category:Personalization extensions/cs Category:Stable extensions/cs