Modul:Labelled list hatnote: Unterschied zwischen den Versionen
Modul:Labelled list hatnote (Quelltext anzeigen)
Version vom 16. Oktober 2021, 03:46 Uhr
, vor 2 JahrenEnhanced with the ability to vary the label based on the namespace(s) of the target page(s), from sandbox
K (Protected "Module:Labelled list hatnote": Highly visible template ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))) |
(Enhanced with the ability to vary the label based on the namespace(s) of the target page(s), from sandbox) |
||
Zeile 51: | Zeile 51: | ||
local labels = {frame.args[1] or defaults.label} | local labels = {frame.args[1] or defaults.label} | ||
labels[2] = frame.args[2] or labels[1] | labels[2] = frame.args[2] or labels[1] | ||
labels[3] = frame.args[3] --no defaulting | |||
labels[4] = frame.args[4] --no defaulting | |||
local template = frame:getParent():getTitle() | local template = frame:getParent():getTitle() | ||
local args = mArguments.getArgs(frame, {parentOnly = true}) | local args = mArguments.getArgs(frame, {parentOnly = true}) | ||
Zeile 73: | Zeile 75: | ||
end | end | ||
label = (#pages == 1 and labels[1] or labels[2]) or defaults.label | label = (#pages == 1 and labels[1] or labels[2]) or defaults.label | ||
for k, v in pairs(pages) do | |||
if mHatnote.findNamespaceId(v) ~= 0 then | |||
label = | |||
( | |||
#pages == 1 and | |||
(labels[3] or labels[1] or defaults.label) or | |||
(labels[4] or labels[2] or defaults.label) | |||
) or defaults.label | |||
end | |||
end | |||
local text = string.format( | local text = string.format( | ||
options.labelForm or defaults.labelForm, | options.labelForm or defaults.labelForm, |