Module:Tag: Difference between revisions

From TwogPedia
(Created page with "local getArgs = require('Module:Arguments').getArgs local cargo = mw.ext.cargo local Tag = {} function Tag.main(frame) local args = getArgs(frame) local tableContainer = mw.html.create('div') if args.name == nil then return tableContainer:wikitext('No tag found') end local tables = 'News' local fields = '_pageName, tags' local cargoArgs = { where = 'tags HOLDS LIKE "%' .. args.name .. '%"' } local results = cargo.query(tables, fields, cargoArgs) lo...")
 
No edit summary
Line 8: Line 8:
local tableContainer = mw.html.create('div')
local tableContainer = mw.html.create('div')
if args.name == nil then return tableContainer:wikitext('No tag found') end
if args.name == nil then return tableContainer:wikitext('No tag found') end
args.name = mw.uri.decode(args.name)
local tables = 'Test'
local tables = 'News'
local fields = '_pageName, tags'
local fields = '_pageName, tags'
local cargoArgs = {
local cargoArgs = {

Revision as of 22:51, 9 May 2023

Documentation for this module may be created at Module:Tag/doc

local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo

local Tag = {}

function Tag.main(frame)
	local args = getArgs(frame)
	
	local tableContainer = mw.html.create('div')
	if args.name == nil then return tableContainer:wikitext('No tag found') end
	
	args.name = mw.uri.decode(args.name)
	
	local tables = 'Test'
	local fields = '_pageName, tags'
	local cargoArgs = {
		where = 'tags HOLDS LIKE "%' .. args.name .. '%"'
	}
	local results = cargo.query(tables, fields, cargoArgs)
	local mapWins = 0
	local mapLosses = 0
	local wins = 0
	local losses = 0
	if #results > 0 then
		for i = 1, #results do
			local result = results[i]
			local news = mw.html.create('div'):wikitext('[[' .. result._pageName .. ']]')
			tableContainer:node(news)
			-- determine if the team in question won
		end
	else
		return tableContainer:wikitext('No news found with the tag "' .. args.name .. '"') 
	end

	return tableContainer
end

return Tag