« Module:Infobox/Configs/Personnage » : différence entre les versions
De Nefald
Autres actions
m icon : person |
Aucun résumé des modifications |
||
| Ligne 15 : | Ligne 15 : | ||
end | end | ||
return nil | return nil | ||
end, | |||
-- Catégorisation automatique selon le type | |||
categories = function(args, config, frame) | |||
local cats = {} | |||
local title = mw.title.getCurrentTitle() | |||
-- On ajoute les catégories uniquement dans le namespace principal (0) | |||
if title.namespace ~= 0 then | |||
return cats | |||
end | |||
-- Catégorie selon le type | |||
if args.type and config.typeField and config.typeField.allowedValues then | |||
local cleanType = mw.text.trim(mw.ustring.lower(args.type)) | |||
local typeDef = config.typeField.allowedValues[cleanType] | |||
if typeDef and typeDef.category then | |||
table.insert(cats, typeDef.category) | |||
end | |||
end | |||
return cats | |||
end, | end, | ||
Version du 20 février 2026 à 08:17
La documentation pour ce module peut être créée à Module:Infobox/Configs/Personnage/doc
local config = {
titre = function(args)
return args.nom or '{{PAGENAME}}'
end,
-- Icône avec type et nom
icone = {
type = 'fas', -- ou 'fab', 'far', 'fal', 'fad'
nom = 'person'
},
image = function(args)
if args.image then
return '[[Fichier:' .. args.image .. '|300px]]'
end
return nil
end,
-- Catégorisation automatique selon le type
categories = function(args, config, frame)
local cats = {}
local title = mw.title.getCurrentTitle()
-- On ajoute les catégories uniquement dans le namespace principal (0)
if title.namespace ~= 0 then
return cats
end
-- Catégorie selon le type
if args.type and config.typeField and config.typeField.allowedValues then
local cleanType = mw.text.trim(mw.ustring.lower(args.type))
local typeDef = config.typeField.allowedValues[cleanType]
if typeDef and typeDef.category then
table.insert(cats, typeDef.category)
end
end
return cats
end,
sections = {
{
titre = 'État civil',
champs = {
{ cle = 'titre', label = 'Titre' },
{ cle = 'surnom', label = 'Surnom' },
{ cle = 'naissance', label = 'Date de naissance' },
{ cle = 'deces', label = 'Date de décès' },
{ cle = 'lieu_naissance', label = 'Lieu de naissance' },
{ cle = 'lieu_residence', label = 'Lieu de résidence' },
{ cle = 'statut', label = 'Statut' },
}
},
{
titre = 'Rôles et activités',
champs = {
{ cle = 'activite', label = 'Activité' },
{ cle = 'organisation', label = 'Organisation' },
{ cle = 'role', label = 'Rôle' },
{ cle = 'croyances', label = 'Croyances' },
}
},
{
titre = 'Affiliations',
champs = {
{ cle = 'famille', label = 'Famille' },
{ cle = 'conjoint', label = 'Conjoint' },
{ cle = 'parents', label = 'Parents' },
{ cle = 'enfants', label = 'Enfants' },
}
},
{
titre = 'Apparence',
champs = {
{ cle = 'sexe', label = 'Sexe' },
{ cle = 'taille', label = 'Taille' },
{ cle = 'poids', label = 'Poids' },
{ cle = 'traits', label = 'Traits' },
}
}
}
}
return config