Extension:MobileDetect/cs
![]() Stav rozšíření: neznáméCategory:Extensions with invalid status/cs |
|
---|---|
Implementace | ZnačkaCategory:Tag extensions/cs |
Popis | Detekuje mobilní zařízení a umožňuje ovládat viditelný obsah pomocí tagů <nomobile> a <mobileonly> , parserových funkcí a CSS tříd. |
Autoři | Matthew Tran (Archivoltdiskuse) |
Správci | Sophivorus |
Nejnovější verze | 2.4 (2024-08-25) |
MediaWiki | 1.35+Category:Extensions with manual MediaWiki version |
Licence | GNU General Public License 3.0 |
Stáhnout | Category:Extensions in Wikimedia version control/cs |
<nomobile> , <mobileonly> , #nomobile , #mobileonly |
|
Čtvrtletní stahování | 25 (Ranked 71st) |
Přeložte rozšíření MobileDetect, používá-li lokalizaci z translatewiki.net | |
Problémy | Otevřené úkoly · Nahlásit chybu |
Rozšíření MobileDetect detekuje mobilní zařízení pomocí rozšíření HTTP_USER_AGENT
v PHP.
Vzhledem k povaze rozšíření by mělo být velmi dobře kompatibilní s novými i starými verzemi MediaWiki.
The extension introduces a function called wfMobileDetect()
, which returns true when a mobile device is detected, and false otherwise.
It also introduces <nomobile>
and <mobileonly>
tags, parser functions and CSS classes which allow users to control which content is displayed only in mobile browsers, and which content is displayed only in desktop browsers.
Instalace
- Stáhněte soubor/y a vložte je do adresáře pojmenovaného
MobileDetect
ve vaší složceextensions/
.
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/MobileDetect - Na konec vašeho souboru LocalSettings.php přidejte následující kód:
wfLoadExtension( 'MobileDetect' );
Dokončeno – Přejděte na stránku Special:Version vaší wiki a zkontrolujte, zda bylo rozšíření úspěšně nainstalováno. Category:Extensions still supporting pre-registration versions
Pro ty, kteří používají MediaWiki 1.38 a starší:
Výše uvedené instrukce se týkají instalace přes wfLoadExtension()
, což je novější způsob instalace rozšíření.
Pokud potřebujete toto rozšíření nainstalovat na starší verzi (MediaWiki 1.38 či starší), musíte místo wfLoadExtension( 'MobileDetect' );
použít:
require_once "$IP/extensions/MobileDetect/MobileDetect.php";
Použití
wfMobileDetect()
If you would like to set a default theme depending on a visitor's browser, you can add this to your LocalSettings.php
:
wfLoadExtension( 'MobileDetect' );
$mobile = wfMobileDetect();
if ( $mobile ) {
$wgDefaultSkin = "chick"; # If mobile
} else {
$wgDefaultSkin = "vector"; # If not mobile
}
With this code, if the visitor's browser shows a user agent from a mobile browser, the default theme will be "chick" instead of "vector". If instead the browser shows a user agent from a desktop/full browser, the default theme will be "vector" instead of "chick".
If you would like a certain extension to be excluded from loading on mobile browsers, you can add this to your LocalSettings.php
:
wfLoadExtension( 'MobileDetect' );
$mobile = wfMobileDetect();
if ( ! $mobile ) {
wfLoadExtension( 'ConfirmEdit' ); # Only load if desktop browser
}
With this code, the reCAPTCHA extension would only load on desktop/full browsers.
<nomobile>
and <mobileonly>
tags
The MobileDetect extension also introduces the <nomobile>
and <mobileonly>
tags, which allow users to control which content is displayed in mobile browsers, and which in desktop/full browsers.
Whatever is wrapped between <mobileonly>
tags will only be displayed in mobile browsers, and whatever is wrapped between <nomobile>
tags will only be displayed in desktop/full browsers.
So for example:
<mobileonly>This will not be displayed in desktop/full browsers, only in mobile browsers</mobileonly>
<nomobile>This will not be displayed in mobile browsers, only in desktop/full browsers</nomobile>
The naming and behaviour of the <mobileonly>
and <nomobile>
tags follows that of the <includeonly>
and <noinclude>
tags.
This fork will render all multi-line content correctly.
#nomobile and #mobileonly parser functions
The MobileDetect extension also introduces the #nomobile
and #mobileonly
parser functions, which work exactly like the <nomobile>
and <mobileonly>
tags, with the difference that their content gets parsed so they can contain stuff like {{{1}}}
and be used in templates.
However, they don't render all multi-line content correctly, so use them mostly for inline content.
This fork will render all multi-line content correctly.
nomobile and mobileonly classes
Alternatively, it is also possible to use the CSS classes directly:
{| class="wikitable nomobile"
|-
| (Some wikitable stuff.)
|}
See also
![]() | Toto rozšíření je zahrnuto v následujících wiki farmách/hostitelích a/nebo balíčcích: Toto není autoritativní seznam. Některé wiki farmy/hostitelé a/nebo balíčky mohou toto rozšíření obsahovat, i když zde nejsou uvedeny. Pro potvrzení se vždy obraťte na své wiki farmy/hostitele nebo balíček. |