Module:QueryBelleSummary

From Victory Belles Community Wiki
Revision as of 21:53, 1 June 2023 by WikiAdmin (talk | contribs) (Created page with "local p = {} local cargo = mw.ext.cargo function p.Main( frame ) local tables = 'MISC_BelleMoreInfo' local fields = 'MISC_BelleMoreInfo.TXT_Summary' -- optional parameters are grouped in one table -- you can omit any or all of them, except join if you use more than one table local args = { where = 'FK_Belle = "{{#replace:{{PAGENAME}}|'|\'}}"', join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.', default ='De...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

Quote-fail.png

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 = 'MISC_BelleMoreInfo.TXT_Summary'
    -- optional parameters are grouped in one table
    -- you can omit any or all of them, except join if you use more than one table
    local args = {
        where = 'FK_Belle = "{{#replace:{{PAGENAME}}|'|\'}}"',
        join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.',
		default ='Description not defined'
    }
    local results = cargo.query( tables, fields, args )
    for r = 1, #results do
        local result = results[r]
        -- Do something with the result table, e.g. result.alias1
    end
end

return p