Safer nicotine wiki
Tobacco Harm Reduction
Jump to navigation
Jump to search
Note that
{{If mobile }} only works outside of the Template: namespace.
This template detects whether it is being used on the mobile version of Wikipedia (en.m.wikipedia.org), and displays different content accordingly.
Rationale
Some features work differently on the mobile website, such as slideshow galleries appearing as ordinary galleries. This template allows better presentation of such content, by e.g. having a "Slideshow" heading when a slideshow is shown, and a "Gallery" heading when a regular gallery is shown.
Usage
{{If mobile|content for mobile website |content for desktop website }}
By default, < span > ...</ span >
tags are used to wrap the specified content. A different tag may be specified using |tag=
E.g. |tag=div
can be used if the content contains block-level elements.
Example
Normal usage
{{If mobile|A mobile user you are!|You are looking at the desktop site}}
Within the Template: namespace
Note that the behaviour is different when within the Template: namespace! (e.g. on this documentation page)
You are currently viewing the {{If mobile|mobile website|desktop website}}.
You are currently viewing the desktop website mobile website .
Namespace and pagename-detecting templates
Namespace
Particular
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
More generic
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
[[Template:{{{2}}}|{{{2}}} ]]
Pagename
[[Template:{{{2}}}|{{{2}}} ]] Detects and acts according to whether it is on a basepage or on any subpage (that is, a ../..
subpage).
[[Template:{{{2}}}|{{{2}}} ]] For pattern matching on the pagename.
Module:Page Can take apart and put together pagenames in several ways.
[[Template:{{{2}}}|{{{2}}} ]] Returns IP-user talkpage, registered-user talkpage or non-user talkpage.
[[Template:{{{2}}}|{{{2}}} ]] For detecting IP-user pages.
[[Template:{{{2}}}|{{{2}}} ]] Pagename has an after-slash part (not in mainspace)
[[Template:{{{2}}}|{{{2}}} ]] Page is subpage /sandbox (template space)
[[Template:{{{2}}}|{{{2}}} ]] Page is subpage /testcases (template space)
[[Template:{{{2}}}|{{{2}}} ]] Page is rootpage (vs. /subpage) (template space)
Others
[[Template:{{{2}}}|{{{2}}} ]] Detects whether it is on a page with a stub template or not.
[[Template:{{{2}}}|{{{2}}} ]] Detects whether it is on a redirect or not.
[[Template:{{{2}}}|{{{2}}} ]] Detects whether page is viewed as a preview or not.
[[Template:{{{2}}}|{{{2}}} ]] Displays different content to IP users and logged-in users.
[[Template:{{{2}}}|{{{2}}} ]] Displays different content to autoconfirmed and non-autoconfirmed users.
[[Template:{{{2}}}|{{{2}}} ]] Displays different content to extended confirmed and non-extended confirmed users.
[[Template:{{{2}}}|{{{2}}} ]] Displays content only to admins.
[[Template:{{{2}}}|{{{2}}} ]] Displays different content to mobile users and desktop users.
[[Template:{{{2}}}|{{{2}}} ]] Detects whether page is viewed with a JavaScript-capable client or not.