Extension:MobileFrontend

The MobileFrontend extension provides a mobile-friendly view. This page is designed for end users who want to install it on their development instance. If you are keen to help us build it and improve it we encourage you to get involved.

Prerequisites

 * Although MediaWiki doesn't require it, PHP must have mbstring support for this extension to work.
 * Release for MediaWiki ≤ 1.24 of MobileFrontend requires the extension Mantle.

Configuration settings
The following variables can be defined in LocalSettings.php after calling.

Note that for a simple site adding  might be all you need to make it Just Work™.

The default skin for MobileFrontend; defaults to SkinMinerva Options to control several functions of the mobile editor. 'anonymousEditing': Whether or not anonymous (not logged in) users should be able to edit. 'skipPreview': Should the mobile edit workflow contain an edit preview (before save) to give the user the possibility to review the new text resulting of their changes or not. Allow editing (uploading) to external CentralAuth-enabled wikis where the user might not be logged in. URL of MediaWiki API entry point to which upload images. If it's an empty string, upload locally. Specify how many edits a user need to use mobile upload. An optional alternative API to query for nearby pages, e.g. https://en.m.wikipedia.org/w/api.php. If set forces nearby to operate in JSONP mode. The content namespace(s) that Special:Nearby and Special:Random should use. Should be one or more of NS_* constants, pipe-separated. ID/database name of the wiki with uploaded images. If null, use local database. URL to the logo used in mobile login and signup form. Should have a height of 72px. Example: "{$wgScriptPath}/mf-logo.png" for the file mf-logo.png in your wiki's root folder. Template used to transcode regular URLs into mobile URLs (optional, and probably an overkill for low-traffic sites). Can either be set as a static domain (eg 'mobile.mydomain.com'), or can use a template based off the host portion of your desktop domain. The token '%h0' represents the first portion of the hostname, '%h1' the second, and so on. For example, to achieve http://en.m.wikipedia.org from http://en.wikipedia.org, you would use: The number of seconds the 'useformat' cookie should be valid (used to keep you on mobile or desktop view of site when manually toggling between the two). If unset, defaults to $wgCookieExpiration. Make the classes, tags and IDs stripped from page content configurable. Each item will be stripped from the page. The extension adds some classes by default. Makes the logos configurable. Example:  Note that 'copyright' controls the image shown in the footer of the mobile page. Set to false to allow search engines to index your mobile pages. So far, Google seems to mix mobile and non-mobile pages in its search results, creating confusion. Set the domain of the stopMobileRedirect cookie. If this value is not set, it will default to the top domain of the host name (eg en.wikipedia.org = .wikipedia.org). If you want to set this to a top domain (to cover all subdomains), be sure to include the preceding '.' (eg .wikipedia.org NOT wikipedia.org). Whether to append a trademark notice to the sitename in the page footer. If set to true or 'unregistered', adds a ™ to the sitename. If set to 'registered' adds a ® to the sitename. If set to false, adds nothing (the default). You can also edit the  interface message directly. Name of the class used for mobile device detection, must be inherited from IDeviceDetector Whether geodata related functionality should be enabled, such as Special:Nearby. Requires GeoData extension. The range in meters that should be searched to find nearby pages on Special:Nearby (defaults to 10km). Pages with smaller parsed HTML size are not cached. Set to 0 to cache everything or to some large value to disable caching completely. Whether or not the MobileFrontend extension autodetects devices for mobile view on its own, rather than using detection at the proxy/webserver layer, or using third party tools like Apache AMF. Depending on your setup, this is probably the easiest method of device detection, though least performant. If this option is set to  file cache must be disabled by setting $wgUseFileCache to   (otherwise autodetection won't be reliable due to cached copies being shown). Controls whether site notices should be shown. Controls whether tablets should be shown the mobile site. Works only if  is. (wiki)text to append to photo description during photo upload. Whether or not to enable the use of the X-Analytics HTTP response header. This header is used for analytics purposes; see Analytics/Kraken/Data Formats/X-Analytics. A CSS selector which is used by mf-photo.js to test whether to prompt the user photo uploads on the current page. When the selector matches no elements the photo uploader will show. Enable CSS animations in all browsers that support them Database key (=page title with underscores instead of spaces etc.) of the category which members will never display mobile view Prefixed names of pages that will never display mobile view Temporary boolean variable to enable/disable progress bars in the photo uploader Minimum available screen width (in pixels) at which a device can be considered a tablet/desktop Devices with available screen of this value and less will have some styles adapted for improved reading on small screens. Whether or not to use the KeepGoing feature. Controls whether API action=mobileview should have every HTML section tidied for invalid markup Requests containing header with this name will be considered as coming from mobile devices. The default value is for backwards compatibility. Set to false to explicitly disable this way of detection. Controls whether the "Minerva as a desktop skin" beta feature is enabled Controls whether the "Nearby pages" beta feature is enabled Controls whether to collapse sections by default. Leave at default  for "encyclopedia style", where the section 0 lead text will always be visible and subsequent sections may be collapsed by default. Set to  for "dictionary style", sections are not collapsed. ID of the App to deep link to replacing the browser. Set  to have no such link. See https://developers.google.com/app-indexing/webmasters/details Scheme to use for the deep link. Per default, 'http' is used. Controls, which page action show and which not. Allowed: edit, talk, upload, watch Whether beta and alpha modes are enabled. If set to true, main page HTML will receive special massaging that removes everything but a few select pieces.
 * $wgMFEditorOptions
 * $wgMFEditorOptions
 * $wgMFUseCentralAuthToken
 * $wgMFUseCentralAuthToken
 * $wgMFPhotoUploadEndpoint
 * $wgMFPhotoUploadEndpoint
 * $wgMFUploadMinEdits
 * 0
 * 0
 * $wgMFNearbyEndpoint
 * $wgMFNearbyEndpoint
 * $wgMFContentNamespace
 * $wgMFContentNamespace
 * $wgMFPhotoUploadWiki
 * $wgMFPhotoUploadWiki
 * $wgMobileFrontendLogo
 * , default no logo
 * , default no logo
 * $wgMobileUrlTemplate
 * $wgMobileUrlTemplate
 * $wgMobileFrontendFormatCookieExpiry
 * $wgMobileFrontendFormatCookieExpiry
 * $wgMFRemovableClasses
 * $wgMFRemovableClasses
 * $wgMFCustomLogos
 * $wgMFCustomLogos
 * $wgMFNoindexPages
 * $wgMFNoindexPages
 * $wgMFStopRedirectCookieHost
 * $wgMFStopRedirectCookieHost
 * $wgMFTrademarkSitename
 * $wgMFTrademarkSitename
 * $wgDeviceDetectionClass
 * $wgDeviceDetectionClass
 * $wgMFNearby
 * $wgMFNearby
 * $wgMFNearbyRange
 * $wgMFNearbyRange
 * $wgMFMinCachedPageSize
 * $wgMFMinCachedPageSize
 * $wgMFAutodetectMobileView
 * $wgMFAutodetectMobileView
 * $wgMFEnableSiteNotice
 * $wgMFEnableSiteNotice
 * $wgMFShowMobileViewToTablets
 * $wgMFShowMobileViewToTablets
 * $wgMFPhotoUploadAppendToDesc
 * $wgMFPhotoUploadAppendToDesc
 * $wgMFEnableXAnalyticsLogging
 * $wgMFEnableXAnalyticsLogging
 * $wgMFLeadPhotoUploadCssSelector
 * $wgMFLeadPhotoUploadCssSelector
 * $wgMFEnableCssAnimations
 * $wgMFEnableCssAnimations
 * $wgMFNoMobileCategory
 * $wgMFNoMobileCategory
 * $wgMFNoMobilePages
 * $wgMFNoMobilePages
 * $wgMFAjaxUploadProgressSupport
 * $wgMFAjaxUploadProgressSupport
 * $wgMFDeviceWidthTablet
 * $wgMFDeviceWidthTablet
 * $wgMFDeviceWidthMobileSmall
 * $wgMFDeviceWidthMobileSmall
 * $wgMFKeepGoing
 * $wgMFKeepGoing
 * $wgMFTidyMobileViewSections
 * $wgMFTidyMobileViewSections
 * $wgMFMobileHeader
 * $wgMFMobileHeader
 * $wgMFEnableMinervaBetaFeature
 * $wgMFEnableMinervaBetaFeature
 * $wgMFEnableNearbyPagesBetaFeature
 * $wgMFEnableNearbyPagesBetaFeature
 * $wgMFCollapseSectionsByDefault
 * $wgMFCollapseSectionsByDefault
 * $wgMFAppPackageId
 * $wgMFAppPackageId
 * $wgMFAppScheme
 * $wgMFAppScheme
 * $wgMFPageActions
 * $wgMFPageActions
 * $wgMFEnableBeta
 * $wgMFEnableBeta
 * $wgMFSpecialCaseMainPage
 * $wgMFSpecialCaseMainPage
 * $wgMFNamespacesWithoutCollapsibleSections
 * $wgMFRSSFeedLink
 * false
 * Sets RSS feed being outputted or not while on mobile version.
 * }
 * $wgMFRSSFeedLink
 * false
 * Sets RSS feed being outputted or not while on mobile version.
 * }

Configuring mobile browser auto detection
See /Configuring browser auto-detection

Configuring the main page
By default, the Main Page on the mobile site is the same page as on desktop. To show an optimized version of your Main page to your mobile users you can disable the desktop Main page simply by following these two rules to add mobile specific content: For example:
 * A selector that is prefixed with mf- will be added to the mobile main page for any project. Any title attributes set on these elements will be promoted into a heading before the section. A title attribute is optional.
 * Any element with the class 'nomobile' will not show on mobile.

Hello

would create a section named Wikimedia Blog with the text 'Hello'. After you saved your Main page, on mobile devices you will see only the sections you added following these rules.

Install Nearby
MobileFrontend provides the Special:Nearby page with a little configuration. To get this to work a few optional steps are required:

Alternatively you can use an alien MediaWiki instance for Nearby with the following 2 lines in your LocalSettings. The nearby endpoint will be used to find related content to a given location.
 * Install GeoData
 * Run update.php
 * in LocalSettings.php add $wgMFNearby = true;
 * Add data to your articles to one or more pages   see the documentation for GeoData for syntax details

Additional tweaks
Get the most out of MobileFrontend by adding these other optional dependencies:

get Special:Nearby and geotag your articles adds images to search and nearby results add Visual editing to your mobile experience.
 * Extension:Geodata -
 * Extension:PageImages -
 * Extension:VisualEditor -

CSS styling
To apply CSS to your mobile theme, edit MediaWiki:Mobile.css, the counterpart of MediaWiki:Common.css.

More information
If you would like to test the mobile extension on a desktop browser or your device doesn't render the mobile version, you can append the following key-value pair to the query string: ?useformat=mobile e.g., https://en.wikipedia.org/wiki/Chuck_Schuldiner?useformat=mobile

If you would like to see the wap version of the mobile extension, use ?useformat=mobile-wap instead.

If you would like to view a page in the beta without enabling it across the entire site you can append to the query string of any page

If you would like to force your wiki to always display in mobile view, add the following to your LocalSettings.php:

Extended action=parse
action=parse accepts extra parameters:
 * mobileformat=: Return rendered page HTML in a mobile format . Prior to MediaWiki 1.23, you could specify mobileformat=html to output HTML for modern phones or mobileformat=wml to output WML for dumb phones (see mailing list messagefor details).
 * noimages: Disable images in mobile output.
 * mainpage: Apply mobile main page transformations.

Example:

action=mobileview
Delivers content optimized for mobile devices for use by mobile apps and dynamic section views. Almost like a restricted-functionality action=parse</tt>, but more flexible and returns separate sections that are always obtained from full-page parse.

Parameters:
 * page</tt>: Title of page to process.
 * sections</tt>: Pipe-separated list of section numbers for which to return text or all</tt> for all sections.
 * redirect</tt>: Whether redirects should be followed, yes</tt> (default) or no</tt>. This parameter is intentionally made similar to the one to index.php.
 * prop</tt>: Which information to get:
 * text</tt>: HTML of selected section(s)
 * sections</tt>: Information about all sections on page
 * normalizedtitle</tt>: Normalized page title, will be returned only if it differs from the specified one.
 * sectionprop</tt>: What information about sections to get: pipe-separated list of value types defined by parser. It's the same as in action=parse: toclevel, level, line, number, index, fromtitle, anchor. "byteoffset" has been excluded as it makes no sense for this action.
 * noimages</tt>: Return HTML without images.
 * noheadings</tt>: Return HTML without headings.

Returned section information also includes the id</tt> for every section - its zero-based number; and for sections that contains references added by Cite, there's also references</tt> data member.

Examples:

Same request for XML:

[//www.mediawiki.org/w/api.php?action=mobileview&page=Extension:MobileFrontend/Example&sections=0&prop=text|sections&format=xmlfm api.php?action=mobileview&page=Extension:MobileFrontend/Example&sections=0&prop=text|sections&format=xml]

prop=extracts
 Migrated to <tvar|ext></> 

WMF sites
On Wikimedia Foundation-run sites, we use Varnish caching servers to check the user agent of your device.

If your user agent appears to be coming from a mobile device, the Varnish servers will set an appropriate 'X-Device' header for your request, and you will be redirected to the MobileFrontend version of an article.

Alternatively, you can click 'Mobile view' in the footer of an article or append "useformat=mobile" to the query string to view an article in the mobile view.

Example:

Varnish server vcl config for X-Device

If you are viewing the mobile version of article but wish to see the desktop-version of that article, you can click 'View this article on regular <SITENAME>' to switch back.

If you want to permanently disable the mobile view for your web browser, you can click 'Permanently disable mobile site', which will set a cookie instructing the WMF servers to always display the desktop version of the site.

Non-WMF sites
For non-WMF sites, you can either set up your configuration to mimic how things are done at the WMF (doing device detection at the proxy layer and setting specific X-Device headers), or you can simply use "?useformat=mobile" to switch an article to use the mobile view.

For Extension Developers
By default resource modules in extensions will not be loaded in mobile view.

Should a module need to be loaded while in mobile view 1>Special:MyLanguage/ResourceLoader/Writing a MobileFrontend friendly ResourceLoader module</>|this guide on writing MobileFrontend friendly modules will be of help.