Differenze tra le versioni di "Modulo:GetTagFromCategory"
m |
m |
||
Riga 39: | Riga 39: | ||
local html = mw.html.create('div') | local html = mw.html.create('div') | ||
:addClass('tagbox') | :addClass('tagbox') | ||
:wikitext('<div class="tagbox-tags-column"><div class="tagbox-tags-body"><span class="tagbox-label"> | :wikitext('<div class="tagbox-tags-column"><div class="tagbox-tags-body"><span class="tagbox-label">Le categorie di questa pagina:</span>' .. tagCode .. '</div></div>') | ||
return tostring(html) | return tostring(html) |
Versione delle 16:48, 5 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 e tag
local renderedTags = {}
for _, category in ipairs(categories) do
category = mw.text.trim(category)
tagCode = tagCode .. "[[Category:" .. category .. "]]"
-- Assegna il codice dell'oggetto tag corrispondente alla categoria
if category == "PA" and not renderedTags["TagPA"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagPA' }
renderedTags["TagPA"] = true
elseif category == "Impresa" and not renderedTags["TagImpresa"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagImpresa' }
renderedTags["TagImpresa"] = true
elseif category == "AltriBandi" and not renderedTags["TagAltriBandi"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagAltriBandi' }
renderedTags["TagAltriBandi"] = true
elseif category == "Mepa" and not renderedTags["TagMepa"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagMepa' }
renderedTags["TagMepa"] = true
elseif category == "Convenzione" and not renderedTags["TagConvenzioni"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagConvenzioni' }
renderedTags["TagConvenzioni"] = true
elseif category == "AQ" and not renderedTags["TagAQ"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagAQ' }
renderedTags["TagAQ"] = true
elseif category == "SDA" and not renderedTags["TagSDA"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagSDA' }
renderedTags["TagSDA"] = true
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">Le categorie di questa pagina:</span>' .. tagCode .. '</div></div>')
return tostring(html)
end
return p