Module:Liste1 : Différence entre versions
Ligne 14 : | Ligne 14 : | ||
end | end | ||
− | local result = mw.ext.cargo.query(query.tables, query.fields, query) | + | local result = mw.ext.cargo.query('Supports','idSupport,video',{groupBy = '_pageName'}) |
+ | for _, row in supports do | ||
+ | supports = row['video'] | ||
+ | end | ||
+ | |||
+ | result = mw.ext.cargo.query(query.tables, query.fields, query) | ||
if not next(result) then | if not next(result) then | ||
return frame:preprocess(args.default or '') | return frame:preprocess(args.default or '') | ||
Ligne 22 : | Ligne 27 : | ||
for _, row in ipairs(result) do | for _, row in ipairs(result) do | ||
tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row } | tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row } | ||
+ | if not tbl[#tbl+1]['video'] then | ||
+ | tbl[#tbl+1]['video'] = supports['idSupports'] | ||
+ | end | ||
end | end | ||
local intro = frame:preprocess(args.intro or '') | local intro = frame:preprocess(args.intro or '') |
Version du 7 décembre 2018 à 14:32
La documentation pour ce module peut être créée à Module:Liste1/doc
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('Supports','idSupport,video',{groupBy = '_pageName'})
for _, row in supports do
supports = row['video']
end
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 }
if not tbl[#tbl+1]['video'] then
tbl[#tbl+1]['video'] = supports['idSupports']
end
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