Module:Ns has subpages
- Afrikaans
- تۆرکجه
- বাংলা
- Banjar
- 閩南語 / Bân-lâm-gí
- भोजपुरी
- Bikol Central
- Bosanski
- Cebuano
- Čeština
- ChiTumbuka
- Corsu
- Dansk
- Euskara
- فارسی
- Føroyskt
- Galego
- ગુજરાતી
- गोंयची कोंकणी / Gõychi Konknni
- 客家語 / Hak-kâ-ngî
- 한국어
- Հայերեն
- हिन्दी
- Hrvatski
- Ilokano
- Bahasa Indonesia
- Jawa
- ಕನ್ನಡ
- ქართული
- Kurdî
- Latviešu
- Lëtzebuergesch
- Lietuvių
- Magyar
- Македонски
- മലയാളം
- مصرى
- ဘာသာမန်
- Bahasa Melayu
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Мокшень
- Монгол
- नेपाली
- 日本語
- پښتو
- Português
- Scots
- Simple English
- سنڌي
- Slovenščina
- کوردی
- Српски / srpski
- Srpskohrvatski / српскохрватски
- தமிழ்
- Taqbaylit
- တႆး
- తెలుగు
- ไทย
- Тоҷикӣ
- اردو
- Tiếng Việt
- 粵語
- 中文
- Bajau Sama
Appearance
From Wikipedia, the free encyclopedia
[画像:Warning] This Lua module is used in system messages, and on approximately 3,570,000 pages, or roughly 6% of all pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module can only be edited by administrators because it is transcluded onto one or more cascade-protected pages.
This module finds whether a given namespace can have subpages.
Usage
From wikitext
From wikitext this module must be used via the {{ns has subpages }} template. Please see the template page for documentation.
From Lua
Usually Lua modules should use mw.site.namespaces[namespace].hasSubpages
rather than this module. But if you have a good reason, it can be accessed like this:
Load the module:
localmNsHasSubpages=require('Module:Ns has subpages')
The subpage information can be found with the ._main function:
mNsHasSubpages._main(ns,frame)
- ns is the namespace name, number, or a page name. It defaults to the current namespace.
- frame is a frame object with which we can call frame:callParserFunction if necessary. This is optional, and intended for internal use.
The above documentation is transcluded from Module:Ns has subpages/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
-- This module implements [[Template:Ns has subpages]]. -- While the template is fairly simple, this information is made available to -- Lua directly, so using a module means that we don't have to update the -- template as new namespaces are added. localp={} functionp._main(ns,frame) -- Get the current namespace if we were not passed one. ifnotnsthen ns=mw.title.getCurrentTitle().namespace end -- Look up the namespace table from mw.site.namespaces. This should work -- for a majority of cases. localnsTable=mw.site.namespaces[ns] -- Try using string matching to get the namespace from page names. -- Do a quick and dirty bad title check to try and make sure we do the same -- thing as {{NAMESPACE}} in most cases. ifnotnsTableandtype(ns)=='string'andnotns:find('[<>|%[%]{}]')then localnsStripped=ns:gsub('^[_%s]*:','') nsStripped=nsStripped:gsub(':.*$','') nsTable=mw.site.namespaces[nsStripped] end -- If we still have no match then try the {{NAMESPACE}} parser function, -- which should catch the remainder of cases. Don't use a mw.title object, -- as this would increment the expensive function count for each new page -- tested. ifnotnsTablethen frame=frameormw.getCurrentFrame() localnsProcessed=frame:callParserFunction('NAMESPACE',ns) nsTable=nsProcessedandmw.site.namespaces[nsProcessed] end returnnsTableandnsTable.hasSubpages end functionp.main(frame) localns=frame:getParent().args[1] ifnsthen ns=ns:match('^%s*(.-)%s*$')-- trim whitespace ns=tonumber(ns)orns end localhasSubpages=p._main(ns,frame) returnhasSubpagesand'yes'or'' end returnp