Module:TestModule: Difference between revisions
Appearance
AdamZachar (talk | contribs) No edit summary |
AdamZachar (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
function p.recurseLineage( frame ) | function p.recurseLineage( frame ) | ||
local | local local_output = frame.args.output | ||
local | local local_parentTopic = frame.args.parentTopic | ||
local topics, errors = mw.ext.externaldata.getExternalData { | local topics, errors = mw.ext.externaldata.getExternalData { | ||
Line 10: | Line 10: | ||
query = "childrenTopics", | query = "childrenTopics", | ||
data = "topicName=topic_name", | data = "topicName=topic_name", | ||
parameters = | parameters = local_parentTopic | ||
} | } | ||
if topics ~= nil then | if topics ~= nil then | ||
local_output = local_output .. "<ul>" | |||
for i, topic in ipairs( | for i, topic in ipairs(local_topics) do | ||
local_output = local_output .. " <li>" .. "[[" .. topic.topicName .. "]]" | |||
p.recurseLineage({output= | p.recurseLineage({output=local_output, parentTopic=local_parentTopic}) | ||
end | end | ||
local_output = local_output .. "</ul>" | |||
end | end | ||
return | return local_output | ||
end | end |
Revision as of 12:13, 10 June 2025
local p = {} --p stands for package
function p.recurseLineage( frame )
local local_output = frame.args.output
local local_parentTopic = frame.args.parentTopic
local topics, errors = mw.ext.externaldata.getExternalData {
source = "CaseData",
query = "childrenTopics",
data = "topicName=topic_name",
parameters = local_parentTopic
}
if topics ~= nil then
local_output = local_output .. "<ul>"
for i, topic in ipairs(local_topics) do
local_output = local_output .. " <li>" .. "[[" .. topic.topicName .. "]]"
p.recurseLineage({output=local_output, parentTopic=local_parentTopic})
end
local_output = local_output .. "</ul>"
end
return local_output
end
function p.topicLineage( frame )
local output = ""
local parentTopic = frame.args.parentTopic
local topics, errors = mw.ext.externaldata.getExternalData {
source = "CaseData",
query = "childrenTopics",
data = "topicName=topic_name",
parameters = parentTopic
}
if topics ~= nil then
output = output .. "<ul>"
for i, topic in ipairs(topics) do
output = output .. " <li>" .. "[[" .. topic.topicName .. "]]"
local childTopics, errors3 = mw.ext.externaldata.getExternalData {
source = "CaseData",
query = "childrenTopics",
data = "topicName=topic_name",
parameters = topic.topicName
}
if childTopics ~= nil then
output = output .. "<ul>"
for i, childTopic in ipairs(childTopics) do
output = output .. " <li>" .. "[[" .. childTopic.topicName .. "]]"
end
output = output .. "</ul>"
end
end
output = output .. "</ul>"
end
return output
end
return p