Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Infobox/Configs/Personnage » : différence entre les versions

De Nefald
Page créée avec « local config = { titre = function(args) return args.nom or '{{PAGENAME}}' end, image = function(args) if args.image then return '300px' end return nil end, sections = { { titre = 'État civil', champs = { { cle = 'titre', label = 'Titre' }, { cle = 'surnom', label = 'Surnom' }, { cle = '... »
 
Aucun résumé des modifications
 
(4 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
local config = {
local config = {
     titre = function(args)
     titre = function(args)
         return args.nom or '{{PAGENAME}}'
         return args.nom or '{{PAGENAME}}'
     end,
     end,
    icone = {
        type = 'fas',
        nom = 'person'
    },


     image = function(args)
     image = function(args)
Ligne 9 : Ligne 15 :
         end
         end
         return nil
         return nil
    end,
    -- STATUT DU PERSONNAGE
    statutField = {
        required = false,
        allowedValues = {
            ['vivant'] = { display = 'Vivant', category = 'Personnage vivant' },
            ['décédé'] = { display = 'Décédé', category = 'Personnage décédé' },
            ['disparu'] = { display = 'Disparu', category = 'Personnage disparu' },
            ['immortel'] = { display = 'Immortel', category = 'Personnage immortel' }
        }
    },
    -- CATÉGORIES AUTOMATIQUES (STATUT UNIQUEMENT)
    categories = function(args, config, frame)
        local cats = {}
        local title = mw.title.getCurrentTitle()
        -- catégories uniquement namespace principal
        if title.namespace ~= 0 then
            return cats
        end
        -- catégorie selon statut
        if args.statut and config.statutField and config.statutField.allowedValues then
            local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut))
            local statutDef = config.statutField.allowedValues[cleanStatut]
            if statutDef and statutDef.category then
                table.insert(cats, statutDef.category)
            end
        end
        return cats
     end,
     end,


Ligne 21 : Ligne 62 :
                 { cle = 'lieu_naissance', label = 'Lieu de naissance' },
                 { cle = 'lieu_naissance', label = 'Lieu de naissance' },
                 { cle = 'lieu_residence', label = 'Lieu de résidence' },
                 { cle = 'lieu_residence', label = 'Lieu de résidence' },
                 { cle = 'statut', label = 'Statut' },
                 { cle = 'statut', label = 'Statut' }
             }
             }
         },
         },
Ligne 30 : Ligne 71 :
                 { cle = 'organisation', label = 'Organisation' },
                 { cle = 'organisation', label = 'Organisation' },
                 { cle = 'role', label = 'Rôle' },
                 { cle = 'role', label = 'Rôle' },
                 { cle = 'croyances', label = 'Croyances' },
                 { cle = 'croyances', label = 'Croyances' }
             }
             }
         },
         },
Ligne 39 : Ligne 80 :
                 { cle = 'conjoint', label = 'Conjoint' },
                 { cle = 'conjoint', label = 'Conjoint' },
                 { cle = 'parents', label = 'Parents' },
                 { cle = 'parents', label = 'Parents' },
                 { cle = 'enfants', label = 'Enfants' },
                 { cle = 'enfants', label = 'Enfants' }
             }
             }
         },
         },
Ligne 48 : Ligne 89 :
                 { cle = 'taille', label = 'Taille' },
                 { cle = 'taille', label = 'Taille' },
                 { cle = 'poids', label = 'Poids' },
                 { cle = 'poids', label = 'Poids' },
                 { cle = 'traits', label = 'Traits' },
                 { cle = 'traits', label = 'Traits' }
             }
             }
         }
         }

Dernière version du 20 février 2026 à 08:34

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,

    icone = {
        type = 'fas',
        nom = 'person'
    },

    image = function(args)
        if args.image then
            return '[[Fichier:' .. args.image .. '|300px]]'
        end
        return nil
    end,

    -- STATUT DU PERSONNAGE
    statutField = {
        required = false,
        allowedValues = {
            ['vivant'] = { display = 'Vivant', category = 'Personnage vivant' },
            ['décédé'] = { display = 'Décédé', category = 'Personnage décédé' },
            ['disparu'] = { display = 'Disparu', category = 'Personnage disparu' },
            ['immortel'] = { display = 'Immortel', category = 'Personnage immortel' }
        }
    },

    -- CATÉGORIES AUTOMATIQUES (STATUT UNIQUEMENT)
    categories = function(args, config, frame)

        local cats = {}
        local title = mw.title.getCurrentTitle()

        -- catégories uniquement namespace principal
        if title.namespace ~= 0 then
            return cats
        end

        -- catégorie selon statut
        if args.statut and config.statutField and config.statutField.allowedValues then
            local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut))
            local statutDef = config.statutField.allowedValues[cleanStatut]

            if statutDef and statutDef.category then
                table.insert(cats, statutDef.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
Les témoins (''cookies'') nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de témoins.