Extension:IfMobile/pt-br

This page is a translated version of the page Extension:IfMobile and the translation is 22% complete.
Manual de extensões do MediaWiki
IfMobile
Estado da versão: estável
Implementação Marcação
Descrição Detects mobile devices and allows to control HTML and template arguments specific for mobile devices and desktops.
Autor(es) Stano Lacko
Mantenedor(es) Stano Lacko
Última versão 0.2.1 (2025-02-17)
MediaWiki 1.39+
Licença Licença BSD Modificada (3 cláusulas)
Download
#ifmobile

The IfMobile extension detects mobile devices using PHP's HTTP_USER_AGENT.

The extension introduces a function called wfMobileDetect(), which returns true when a mobile device is detected, and false otherwise. The extention introduces parser function #ifmobile which allow users to control HTML content (attributes' values) and Template arguments for mobile devices and desktop devices. It creates also separated cache for mobile and desktop devices. It is very helpful, when it is very complicated to made two outputs one for mobile, one for desktop and show proper output on visitors device. IfMobile check visitor device and shows output with specific html styles, table colspan/rowspan, etc depends on device type.

  • Baixe e coloque o(s) arquivo(s) num diretório nomeado IfMobile na sua pasta extensions/.
  • Adicione o seguinte código ao final do seu arquivo LocalSettings.php :
    wfLoadExtension( 'IfMobile' );
    
  • Yes Concluído – Navegue à página Special:Version em sua wiki para verificar se a instalação da extensão foi bem sucedida.

Usage

#ifmobile and #mobileonly parser functions

The IfMobile extension introduces the #ifmobile parser function.

Different HTML attribute for mobile and desktop

<div style="background-color:{{#ifmobile:color for mobile devices|color for desktop devices}}">Content</div>

This solution not need to create content twice as in MobileDetect extension. Because both types of devices received different HTML output (mobile with different color as desktop).

Different Template arguments for mobile and desktop

Main advantage is to control arguments send to templates and also arguments in templates themself.

{{Feature|name=City|variant=image|size={{#ifmobile:x20px|x15px}}|text=In city with blahblahblah}}

Different content for mobile and desktop

Quando for necessário criar conteúdo diferente (semelhante ao MobileDetect).

<div>{{#ifmobile:Content only for mobiles|Content only for desktop}}</div>

Conteúdo enviado somente para desktop

Essa solução reduz o arquivo HTML enviado para dispositivos móveis, pois não contém conteúdo de desktop oculto como na extensão MobileDevice.

<div>{{#ifmobile:|Content only for desktop}}</div>

Ver também