Jump to content

Module:TestModule: Difference between revisions

From NewsWikiTestbed
AdamZachar (talk | contribs)
No edit summary
AdamZachar (talk | contribs)
No edit summary
Line 13: Line 13:
   }
   }


  if topics == nil then end
  if topics == nil then return output end


  output = output .. "<ul>"
  output = output .. "<ul>"
Line 28: Line 28:
   }
   }


   if childTopics == nil then end
   if childTopics == nil then break end


   output = output .. "<ul>"
   output = output .. "<ul>"

Revision as of 11:51, 10 June 2025


local p = {} --p stands for package

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 return output end

 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 break end

  output = output .. "<ul>"

  for i, childTopic in ipairs(childTopics) do
   output = output .. " <li>" .. "[[" .. childTopic.topicName .. "]]"
  end

  output = output .. "</ul>"

 end

 output = output .. "</ul>"

 return output
end


return p