Differenze tra le versioni di "Modulo:GetTagFromCategory"

Da Wiki Acquisti in rete PA.
m
m
Riga 11: Riga 11:
      
      
     -- Assegna l'oggetto tag corrispondente alla categoria
     -- Assegna l'oggetto tag corrispondente alla categoria
     if category == "Pa" then
     if category == "PA" then
       tagCode = tagCode .. frame:expandTemplate{ title = 'TagPA' }
       tagCode = tagCode .. frame:expandTemplate{ title = 'TagPA' }
     elseif category == "Categoria2" then
     elseif category == "AltriBandi" then
       tagCode = tagCode .. frame:expandTemplate{ title = 'TagCategoria2' }
       tagCode = tagCode .. frame:expandTemplate{ title = 'TagAltriBandi' }
    elseif category == "Categoria3" then
      tagCode = tagCode .. frame:expandTemplate{ title = 'TagCategoria3' }
     end
     end
   end
   end

Versione delle 18:02, 1 giu 2023

La documentazione per questo modulo può essere creata in Modulo:GetTagFromCategory/man

local p = {}

function p.generateTagCode(frame)
  local categories = mw.text.split(frame.args[1], ",")
  local tagCode = ""

  -- Genera i codici di categoria
  for _, category in ipairs(categories) do
    category = mw.text.trim(category)
    tagCode = tagCode .. "[[Category:" .. category .. "]]"
    
    -- Assegna l'oggetto tag corrispondente alla categoria
    if category == "PA" then
      tagCode = tagCode .. frame:expandTemplate{ title = 'TagPA' }
    elseif category == "AltriBandi" then
      tagCode = tagCode .. frame:expandTemplate{ title = 'TagAltriBandi' }
    end
  end

  -- Genera il codice HTML con i tag
  local html = mw.html.create('div')
    :addClass('tagbox')
    :wikitext('<div class="tagbox-tags-column"><div class="tagbox-tags-body"><span class="tagbox-label">I tag di questa pagina:</span>' .. frame:expandTemplate{ title = 'Categoria1' } .. frame:expandTemplate{ title = 'Categoria2' } .. frame:expandTemplate{ title = 'Categoria3' } .. '</div></div>')

  return tagCode .. tostring(html)
end

return p