66 403
contributi
mNessun oggetto della modifica |
mNessun oggetto della modifica |
||
(17 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 415: | Riga 415: | ||
-- @return A bullet list of backlinks | -- @return A bullet list of backlinks | ||
function p.ListBackReferences(frame) | function p.ListBackReferences(frame) | ||
-- See example here https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.getQueryResult.md | |||
-- See also here https://doc.semantic-mediawiki.org/md_content_extensions_SemanticScribunto_docs_mw_8smw_8getQueryResult.html | |||
local AllBackReferences = {} | local AllBackReferences = {} | ||
--[=[ | |||
local QueryResult = mw.smw.ask('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID|format=broadtable') | local QueryResult = mw.smw.ask('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID|format=broadtable') | ||
if not QueryResult then | if not QueryResult then | ||
Riga 434: | Riga 436: | ||
end | end | ||
return table.concat(AllBackReferences, string.char(10)) | return table.concat(AllBackReferences, string.char(10)) | ||
end | end | ||
]=] | |||
--local QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID') | |||
--local queryResult = mw.smw.getQueryResult( frame.args ) | |||
local QueryResult = mw.smw.getQueryResult('[[Riferimento::' .. mw.title.getCurrentTitle().text .. ']]|?DataTrek ID') | |||
if QueryResult == nil then | |||
return "''Nessun risultato''" | |||
end | |||
if type(QueryResult) == "table" then | |||
local Row = "" | |||
for k, v in pairs(QueryResult.results) do | |||
--[=[if v.fulltext and v.fullurl then | |||
myResult = myResult .. k .. " | " .. v.fulltext .. " " .. v.fullurl .. " | " .. "<br/>" | |||
else | |||
myResult = myResult .. k .. " | no page title for result set available (you probably specified ''mainlabel=-')" | |||
end]=] | |||
if string.sub(v.fulltext, 1, 5) == "File:" then | |||
Row = "[[:" .. v.fulltext .. "]]" --string.sub(v.fulltext, 3) | |||
else | |||
Row = "[[" .. v.fulltext .. "]]" | |||
end | |||
Row = Row .. " - " .. v.printouts['DataTrek ID'][1] | |||
AllBackReferences[#AllBackReferences + 1] = "*" .. Row | |||
end | |||
return table.concat(AllBackReferences, string.char(10)) | |||
else | |||
return "''No table''" | |||
end | |||
return queryResult | |||
end | end | ||
return p | return p |