![]() Release status: stable | |
---|---|
![]() | |
Implementation | Special page,API |
Description | Adds a central sitenotice |
Author(s) | Andrew Russell Green,Matthew Walker,Adam Roses WightFormerly:Brooke Vibber,Tomasz Finc,Trevor Parscal,Ryan Kaldari |
Latest version | 2.6.1 (continuous updates) |
Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
Database changes | Yes |
Tables | cn_notices cn_assignments cn_templates cn_notice_languages cn_notice_projects cn_notice_countries cn_notice_regions cn_template_mixins cn_notice_mixins cn_notice_mixin_params cn_known_devices cn_template_devices cn_known_mobile_carriers cn_notice_mobile_carriers cn_notice_log cn_template_log |
License | GNU General Public License 2.0 or later |
Download | |
Example | Special:CentralNotice on Meta (read-only) |
| |
Translate the CentralNotice extension if it is available at translatewiki.net | |
Issues | Open tasks ·Report a bug |
TheCentralNotice extension delivers announcements (usually in the form of banners) to Wikimedia wikis.It is used heavily by theFundraising team to solicit donations, and for announcements of interest to Wikimedia communities and users.CentralNotice can target announcements by country, language, project, device and logged-in status.
This page has information for CentralNotice developers andwiki administrators who want to install CentralNotice on their own sites.To learn how to create and configure CentralNotice campaigns, please seeHelp:CentralNotice onMeta-Wiki.For information about the CentralNotice setup on the Wikimedia Foundation's cluster, seeCentralNotice onWikitech.
CentralNotice allows central distribution of announcements to many wikis (calledsubscribing wikis) from a central wiki (theinfrastructure wiki).If you only need to post messages to a single wiki, consider usingSitenotice instead.
wfLoadExtension('CentralNotice');
Geo
cookie is pre-populated, however, its value will be used. For local development, you can enable a client-side implementation that useshttps://freegeoip.net as follows. For more information, see#GeoIP lookup.$wgCentralNoticeGeoIPBackgroundLookupModule='ext.centralNotice.freegeoipLookup';
php maintenance/run.php update
LocalSettings.php
and set ...$wgNoticeInfrastructure
to true$wgNoticeProjects
to be an array of projects that will subscribe to the central wiki. For examplearray( 'wikipedia', 'wiktionary' )
sysop
group is the only group with the ability to administer CentralNotice. If additional groups are needed, assign them thecentralnotice-admin
andeditinterface
permissions.EditLocalSettings.php
and set...
$wgNoticeInfrastructure
tofalse
;$wgNoticeProject
to be an entry in$wgNoticeProjects
;$wgCentralHost
to the protocol (potentially neutral) and domain of the central wiki. For example//meta.wikimedia.org
;$wgCentralSelectedBannerDispatcher
to the URL of Special:BannerLoader on the central wiki, for example://meta.wikimedia.org/w/index.php/Special:BannerLoader
;$wgCentralDBname
to the name of the infrastructure wiki's database, or$wgCentralNoticeApiUrl
to the API endpoint of the infrastructure wiki; and$wgCentralBannerRecorder
to the URL of Special:RecordImpression on the central wiki. For example://meta.wikimedia.org/w/index.php/Special:RecordImpression
.For most development tasks, you can use a single wiki in both infrastructure and subscribing roles.Following are sample lines to include inLocalSettings.php
.(See notes in comments.)
wfLoadExtension('CentralNotice');$wgNoticeInfrastructure=true;$wgNoticeProject='centralnoticeproject';# 'centralnoticeproject' can be any string$wgNoticeProjects=[$wgNoticeProject];$wgCentralHost=$wgServer;$wgCentralSelectedBannerDispatcher="$wgServer$wgScriptPath/index.php?title=Special:BannerLoader";$wgCentralDBname=$wgDBname;$wgCentralNoticeGeoIPBackgroundLookupModule='ext.centralNotice.freegeoipLookup';
All code that runs on subscribing wikis should be smoke-tested withMobileFrontend, to ensure they work on the mobile version of the site.
Some CentralNotice features require other MediaWiki extensions, includingEventLogging andTranslate.
The WMFFundraising tech team are the maintainers of CentralNotice.For questions about installation, bug reports, or usage of CentralNotice please send an email to the mailing listwikitech-l@lists.wikimedia.org or join us in theIRC channel#wikimedia-fundraisingconnect.
centralnotice-admin
— Permission required to modify campaigns and banners. Relevant only to the infrastructure wikis (see alsobugzilla:26377).editinterface
- required to edit banner content.From a user facing perspective, the high level CentralNotice objects arecampaigns (a.k.a. notices) andbanners (a.k.a. templates).These are affected by the back end concepts ofselectors andallocation.
By default, CentralNotice has no client-side GeoIP lookup service configured.This is optimised for the Wikimedia Foundation production configuration where Varnish populates theGeo
cookie from the server-side.(Seewikitech:Geolocation.)You can configure CentralNotice to use a custom data source client-side through theCentralNoticeGeoIPBackgroundLookupModule
configuration variable.This variable expects the name of a ResourceLoader module that exports a function.The function will be called without parameters and should return a Promise that resolves with an object containing the following properties:
Full usage instructions can be found atmeta:Help:CentralNotice.
(TODO: move and expand this snippet)
Add any of the following URL parameters to preview a specific banner, defeat "diet" schemes, or debug pseudorandom banner selection.
?banner=<bannername>
to the end of the URL.For example,
If there is a problematic banner in the page, you can identify which banner is active by opening your developer console and inspecting the value of:mw.centralNotice.bannerData.bannerName
.
Bannersdo not display on pages in theSpecial
namespace, as well as edit pages and diff pages.
CentralNotice adds two API modules,centralnoticechoicedata
andcentralnoticequerycampaign
.(The API modulecentralnoticeallocations was deprecated and removed in MediaWiki 1.25.)
![]() | The following documentation is the output ofSpecial: |
Get data needed to choose a banner for a given project and language
The project to get banner choice data for.
The language to get banner choice data for.
![]() | The following documentation is the output ofSpecial: |
Get all configuration settings for a campaign.
Campaign name. Separate multiple values with a "|" (vertical bar).
![]() | This extension is being used on one or moreWikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia'sCommonSettings.php andInitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki'sSpecial:Version page. |
![]() | This extension is included in the following wiki farms/hosts and/or packages:This is not an authoritative list.Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here.Always check with your wiki farms/hosts or bundle to confirm. |