„Wikipedia:Lua/Modul/PageUtil/en“ – Versionsunterschied
Erscheinungsbild
Die Seite wurde neu angelegt: „{{LuaModuleDoc}} <onlyinclude>'''<code>PageUtil</code>''' – Module with functions for entire wiki pages. == {{Anker|template}} Functions for templates == ; getCategories {{Anker|getCategories}} : Which categories apply to this page? : ''Parameter (optional):'' :; 1 :: Page name :: ''Default:'' Current page : Result is a list of category titles separated by <code>|</code> :* „{{#invoke:PageUtil|getCategories}}“ ; getContentModel {{Anker|getContentM…“ |
K Klaus verschob die Seite AufEinWort:Lua/Modul/PageUtil/en nach Wikipedia:Lua/Modul/PageUtil/en, ohne dabei eine Weiterleitung anzulegen |
(kein Unterschied)
| |
Version vom 14. September 2026, 08:40 Uhr
| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | ||
Weiterleitung der Diskussionsseite fehlt
PageUtil – Module with functions for entire wiki pages.
Functions for templates
- getCategories
- Which categories apply to this page?
- Parameter (optional):
- 1
- Page name
- Default: Current page
- Result is a list of category titles separated by
|- „Wikipedia:Lua/Modul/Dokumentation|•Lua|•Modul|•en|•PageUtil|AufEinWort:Obereinordnung fehlt|AufEinWort:Untereinordnung fehlt|AufEinWort:Ordnung fehlt|AufEinWort:Einordnung fehlt“
- getContentModel
- Parameter (optional):
- 1
- Page name
- Default: Current page
- Result is content model of this page
- getProtection
- Is this page protected?
- Parameters (all optional):
- 1
- Page name
- Default: Current page
- 2
- action
- Default:
edit - Others:
move/create/upload
- Result is one of: empty,
½,¾,1 - isRedirect
- Is this a redirect page?
- Result is empty, if transcluded in regular page; on redirect page a non-empty string
- merge
- Merge pages.
- Result is a string concatenating particular content without line breaks.
- Up to 200 pages and sections might be transcluded.
- Parameters (all optional):
- 1
- First text element.
- One of following formats:
[[page name]]- Transclude entire page.
- Links on this page will be replaced by internal links.
#lst: [[page name]]mark
#lstx: [[page name]]mark- Transclude section of a page.
- Since it is unknown which fragments could be accessed, for this page no inner links will be modified.
- Other arbitrary text.
- Line breaks can be created safely by the following syntax:
| <nowiki />
=== Conclusion ===
<nowiki />
- 2 3 4 5 6 7 8 9 …
- More text elements, any number.
- The text elements will be transcluded in numerical sequence of parameter name.
- failsafe
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
- ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
- administrate global updating and linking of module codes via Wikidata.
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
| Value | Result | current |
|---|---|---|
nothingfalse
|
local version ID | »2025-01-01« |
| Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata
|
version ID of global upstream
|
»2025-01-01« |
item
|
ID of the Wikidata item
|
Q89064539
|
~
|
Corresponding version ID locally and registered at Wikidata
|
»2025-01-01« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.
| ||
Functions for Lua modules (API)
Some functions described above can be used by other modules per require():
local lucky, PageUtil = pcall( require, "Module:PageUtil" )
if type( PageUtil ) == "table" then
PageUtil = PageUtil()
else
-- error case; PageUtil contains message
return "<span class=\"error\">" .. PageUtil .. "</span>"
end
Subsequently there are available:
- PageUtil.getProtection( source, stage )
-
- source – (optional) string or mw.title for that page
- stage – (optional) string with action
- Returns number, one of: 0, 0.5, 0.75, 1
- PageUtil.merge( args, frame )
-
- args – table with parameters like for templates
- frame – object or
nil
- PageUtil.failsafe( since )
Directly available are:
mw.title.getCurrentTitle().categories
mw.title.getCurrentTitle().contentModel
mw.title.getCurrentTitle().isRedirect
Usage
General library; no limitations.
Dependencies
None.