Template:IsDesktop/doc

Revision as of 15:16, 11 September 2026 by ReisuDesign (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This is the documentation page for IsDesktop.
It contains usage information, categories, and other content not part of the original template page.
Template copied from Obey Me Wiki

Note: This template must have the template type "Notice" in order to work properly.
This template allows showing different content for mobile skin and for desktop skin - not just selectively hiding content, but actually having different Wikitext. (See also #Technical explanation)

Syntax

edit
{{#if:{{IsDesktop}}
| Content for desktop
| Content for mobile
}}

Examples

edit
{{#if:{{IsDesktop}}
| You are now on desktop view. [{{fullurl:{{FULLPAGENAME}}|mobileaction=toggle_view_mobile}} <span class="wds-button">Switch to mobile view</span>]
| You are now on mobile view. [{{fullurl:{{FULLPAGENAME}}|mobileaction=toggle_view_desktop}} <span class="wds-button">Switch to desktop view</span>]
}}

You are now on desktop view. Switch to mobile view

<div class="mw-collapsible {{#if:{{IsDesktop}}||mw-collapsed}}">
Collapsed by default only on mobile
</div>

Collapsed by default only on mobile

(On mobile, the collapsible above is collapsed by default,
and an "Expand" button should appear here on the right -->
while on desktop it is expanded by default)

Technical explanation

edit

Certain template types behave differently on the mobile view (see Help:Template types on Community Central). The template type "Notice", which is intended for editor and maintenance notes, is totally stripped out on the mobile skin since it is mainly aimed for readers.

By combining this behavior with the #if parser function, we can make the parser to render different Wikitext for desktop and for mobile.