Модуль:RandomMembers: відмінності між версіями
| Admin (обговорення | внесок) Немає опису редагування | Admin (обговорення | внесок)  Немає опису редагування | ||
| Рядок 2: | Рядок 2: | ||
| function p.showRandomMembers(frame) | function p.showRandomMembers(frame) | ||
|      local category =  |      local category = "Учасники_спільноти_MCC"  -- Your category name | ||
|      local  |      local pages = mw.smw.getQueryResult('[[Category:' .. category .. ']]|?Modification date|sort=Modification date|order=rand|limit=4') | ||
|     if not pages or not pages.results then | |||
|          return "No results found." | |||
|      end | |||
|      local output = {} |      local output = {} | ||
|      for _, page in ipairs(pages.results) do | |||
|          local title = page.fullText or page.title | |||
|          table.insert(output, string.format('<p><a href="/wiki/%s">%s</a></p>', mw.uri.encode(title, 'WIKI'), title)) | |||
|          local  | |||
|      end |      end | ||
Версія за 22:33, 21 квітня 2024
Документацію для цього модуля можна створити у Модуль:RandomMembers/документація
local p = {}
function p.showRandomMembers(frame)
    local category = "Учасники_спільноти_MCC"  -- Your category name
    local pages = mw.smw.getQueryResult('[[Category:' .. category .. ']]|?Modification date|sort=Modification date|order=rand|limit=4')
    
    if not pages or not pages.results then
        return "No results found."
    end
    local output = {}
    for _, page in ipairs(pages.results) do
        local title = page.fullText or page.title
        table.insert(output, string.format('<p><a href="/wiki/%s">%s</a></p>', mw.uri.encode(title, 'WIKI'), title))
    end
    return table.concat(output, "\n")
end
return p