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/Core » : différence entre les versions

De Nefald
Hiob (discussion | contributions)
m Parserfunctions
Hiob (discussion | contributions)
Supprimé l'ancienne section d'ajout d'icône avec :wikitext() Ajouté le traitement de l'icône après la construction du HTML Utilisé preprocess() pour traiter le parser function FontAwesome Injecté l'icône dans le HTML final avec gsub()
Balises : Modification par mobile Modification par le web mobile
Ligne 110 : Ligne 110 :
     root:node(body)
     root:node(body)
      
      
-- Ajouter l'icône en bas à droite
    -- Traiter l'icône APRÈS avoir construit tout le HTML
if config.icone then
     local finalResult = tostring(root)
     local iconeDiv = mw.html.create('div')
        :addClass('infobox-icon-bottom')
      
      
     local iconeType = config.icone.type or 'fas'
     if config.icone then
    local iconeNom = config.icone.nom
        local iconeType = config.icone.type or 'fas'
   
        local iconeNom = config.icone.nom
    -- Utiliser mw.getCurrentFrame() si frame n'est pas disponible
       
    local currentFrame = frame or mw.getCurrentFrame()
        -- Utiliser mw.getCurrentFrame() si frame n'est pas disponible
    local iconeContent = '{{#' .. iconeType .. ':' .. iconeNom .. '}}'
        local currentFrame = frame or mw.getCurrentFrame()
   
        local iconeContent = '{{#' .. iconeType .. ':' .. iconeNom .. '}}'
    if currentFrame then
       
        iconeContent = currentFrame:preprocess(iconeContent)
        if currentFrame then
            iconeContent = currentFrame:preprocess(iconeContent)
        end
       
        -- Créer la div d'icône séparément et l'ajouter au résultat
        local iconeHtml = string.format(
            '<div class="infobox-icon-bottom">%s</div>',
            iconeContent
        )
       
        -- Injecter l'icône juste avant la fermeture de la div principale
        finalResult = finalResult:gsub('</div>$', iconeHtml .. '</div>')
     end
     end
      
      
    iconeDiv:wikitext(iconeContent)
     return finalResult
    root:node(iconeDiv)
end
   
     return tostring(root)
end
end


return p
return p
Les témoins (''cookies'') nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de témoins.