Module:CRTModel: Difference between revisions

No edit summary
No edit summary
Line 225: Line 225:
if hasDocuments then
if hasDocuments then
-- Create UL element
-- Use #ask with array format
local ul = mw.html.create('ul')
ul:css('margin', '0'):css('padding-left', '1.5em')
-- Use #ask with array format - simpler separators
local docsQueryWikitext =
local docsQueryWikitext =
'{{#ask:\n' ..
'{{#ask:\n' ..
Line 244: Line 240:
local docsResult = frame:preprocess(docsQueryWikitext)
local docsResult = frame:preprocess(docsQueryWikitext)
-- Parse the result - format should be: PageName§Type§URL¶PageName§Type§URL
-- DEBUG: Show raw result
if docsResult and trim(docsResult) then
local debugDiv = mw.html.create('div')
-- Split by paragraph symbol (documents separator)
debugDiv:css('background', '#fee'):css('padding', '5px'):css('margin', '5px 0')
for docLine in docsResult:gmatch('[^¶]+') do
debugDiv:wikitext('DEBUG docsResult: <pre>' .. mw.text.encode(docsResult or 'nil') .. '</pre>')
docLine = trim(docLine)
td:node(debugDiv)
if docLine and docLine ~= '' then
-- Split by section symbol (properties separator)
-- Create UL element
local parts = {}
local ul = mw.html.create('ul')
for part in docLine:gmatch('[^§]+') do
ul:css('margin', '0'):css('padding-left', '1.5em')
table.insert(parts, trim(part))
end
-- Add a test item to verify UL works
local testLi = ul:tag('li')
-- parts[1] = page name, parts[2] = type, parts[3] = URL
testLi:wikitext('[https://example.com Test Link]')
if #parts >= 3 then
local docType = parts[2]
local docUrl = parts[3]
if docUrl and docUrl ~= '' then
local displayText = (docType and docType ~= '') and docType or 'Document'
-- Create list item with link
local li = ul:tag('li')
li:wikitext('[' .. docUrl .. ' ' .. displayText .. ']')
end
end
end
end
end
-- Add the UL to the td
td:node(ul)
td:node(ul)
MediaWiki Appliance - Powered by TurnKey Linux