Module:QueryBelleSummary: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Protected "Module:QueryBelleSummary": Prevent editing of templates ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
||
| (15 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
local cargo = mw.ext.cargo | local cargo = mw.ext.cargo | ||
function p. | function p.main ( frame ) | ||
local tables = | local tables = "MISC_BelleMoreInfo" | ||
local fields = | local fields = "TXT_Summary" | ||
local | local cargoArgs = { | ||
where = | where = "MISC_BelleMoreInfo.FK_Belle = '" .. frame.args.belle .. "'", | ||
default ='Description not defined', | default ='Description not defined', | ||
limit = 1 | limit = 1 | ||
} | } | ||
local results = cargo.query( tables, fields, | local results = cargo.query( tables, fields, cargoArgs ) | ||
for r = 1, #results do | for r = 1, #results do | ||
local result = results[r] | local result = results[r] | ||
if result == nil then | if result == nil then | ||
return 'Empty Cargo...' | |||
else | else | ||
return result.TXT_Summary | return result.TXT_Summary | ||
Latest revision as of 10:13, 2 June 2023
Description[edit source]
Retrieve a Belle's ingame Summary text. Only necessary because of a conflict between ConfirmEdit/QuestyCaptcha and Cargo that resulted in Cargo-stored text containing double quotes turning into the HTML escaped version when retrieved like the below.
To Use[edit source]
This code was written for the NewBellePage template but if needed elsewhere, copy and paste the following.
{{#invoke:QueryBelleSummary|main|belle={{#replace:{{PAGENAME}}|'|\'}}}}
If not using the name of the page, swap PAGENAME with the Belle's name. The "replace" code is needed to handle names that contain single quotes which would otherwise cause database errors if not properly escaped prior to being queried for.
On NewBellePage, the text is also italicized.
local p = {}
local cargo = mw.ext.cargo
function p.main ( frame )
local tables = "MISC_BelleMoreInfo"
local fields = "TXT_Summary"
local cargoArgs = {
where = "MISC_BelleMoreInfo.FK_Belle = '" .. frame.args.belle .. "'",
default ='Description not defined',
limit = 1
}
local results = cargo.query( tables, fields, cargoArgs )
for r = 1, #results do
local result = results[r]
if result == nil then
return 'Empty Cargo...'
else
return result.TXT_Summary
end
end
end
return p