Differenze tra le versioni di "Modulo:GetTagFromCategory"
m |
m |
||
(7 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 6: | Riga 6: | ||
-- Genera i codici di categoria e tag | -- Genera i codici di categoria e tag | ||
local renderedTags = {} | |||
for _, category in ipairs(categories) do | for _, category in ipairs(categories) do | ||
category = mw.text.trim(category) | category = mw.text.trim(category) | ||
Riga 11: | Riga 12: | ||
-- Assegna il codice dell'oggetto tag corrispondente alla categoria | -- Assegna il codice dell'oggetto tag corrispondente alla categoria | ||
if category == "PA" then | if category == "PA" and not renderedTags["TagPA"] then | ||
tagCode = tagCode .. "{ | tagCode = tagCode .. frame:expandTemplate{ title = 'TagPA' } | ||
elseif category == "AltriBandi" then | renderedTags["TagPA"] = true | ||
tagCode = tagCode .. | elseif category == "Impresa" and not renderedTags["TagImpresa"] then | ||
elseif category == " | tagCode = tagCode .. frame:expandTemplate{ title = 'TagImpresa' } | ||
tagCode = tagCode .. "{{ | 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 == "Convenzioni" 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 | |||
elseif category == "Bozza" and not renderedTags["TagBozza"] then | |||
tagCode = tagCode .. frame:expandTemplate{ title = 'TagBozza' } | |||
renderedTags["TagBozza"] = true | |||
end | end | ||
end | end | ||
Riga 23: | Riga 42: | ||
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 | return tostring(html) | ||
end | end | ||
return p | return p |
Versione attuale delle 17:10, 19 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 == "Convenzioni" 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
elseif category == "Bozza" and not renderedTags["TagBozza"] then
tagCode = tagCode .. frame:expandTemplate{ title = 'TagBozza' }
renderedTags["TagBozza"] = 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