Fortnite Wiki

Crossover banner.jpg
Fortnite wiki on Fandom

READ MORE

Fortnite Wiki
Advertisement
Fortnite Wiki

Documentation[purge]

This template lets you get around the |no html bug that Cargo has by avoiding |format=template.

To use, preface query arguments with q?. Even if you are only using one table, use |q?tables=. You may additionally specify |template=, |intro=, |outro=, and |delimiter=.

Use Lua names of all query parameters, so |q?join=, |q?groupBy, etc.

For simplicity of code, the named args parameter is required to be Yes, and you do not need to specify it.

Parameters & Invocation

{{#invoke:CargoQuery|main
|q?tables= 	corresponds to table / tables
|q?join= 	corresponds to join on
|q?fields= 	corresponds to fields
|q?where= 	corresponds to where
|q?groupBy= 	corresponds to group by
|q?having= 	corresponds to having
|q?orderBy= 	corresponds to order by
|q?limit= 	corresponds to limit
|template=
|intro=
|outro=
|delimiter=
|default=
}}

About


local p = {}
function p.main(frame)
	if frame == mw.getCurrentFrame() then
		args = require('Module:ProcessArgs').merge(true)
	else
		frame = mw.getCurrentFrame()
	end
	
	local query = {}
	for k, v in pairs(args) do
		if string.sub(k, 0, 2) == 'q?' then
			query[string.sub(k, 3)] = v
		end
	end
	
	local result = mw.ext.cargo.query(query.tables, query.fields, query)
	if not next(result) then
		return frame:preprocess(args.default or '')
	end
	local tbl = {}
	for _, row in ipairs(result) do
		tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row }
	end
	local intro = frame:preprocess(args.intro or '')
	local outro = frame:preprocess(args.outro or '')
	return intro .. table.concat(tbl,args.delimiter or '') .. outro
	
end
return p
Advertisement