« Module:Catégorie par date » : différence entre les versions
Apparence
wp>GrandEscogriffe plus fiable (mais plus coûteux) : recherche dans la chaîne de caractères |
m 1 version importée |
(Aucune différence)
| |
Dernière version du 29 juin 2025 à 00:56
La documentation pour ce module peut être créée à Module:Catégorie par date/doc
local p = {}
function p.categorize(frame)
local args1 = frame:getParent().args
local args2 = frame.args
local dateparam = args1[1]
if (not dateparam) or dateparam == '' then return nil end
local prefix = args2.prefix
local suffix = args2.suffix
if prefix then prefix = prefix .. ' ' else prefix = '' end
if suffix then suffix = ' ' .. suffix else suffix = '' end
local default = args2.default or 'Échec de Module:Catégorie par date'
local datemin = tonumber(args2.datemin) or 2024
local datemax = tonumber(args2.datemax) or 2024
local catstring
for datenum = datemin,datemax do
local datestring = tostring(datenum)
if mw.ustring.find(dateparam,datestring) then
catstring = '[[Category:' .. prefix .. datestring .. suffix .. ']]'
return catstring
end
end
catstring = '[[Category:' .. default .. ']]'
return catstring
end
return p