Модуль:RandomMembers: відмінності між версіями
| Admin (обговорення | внесок) Немає опису редагування | Admin (обговорення | внесок)  Немає опису редагування | ||
| Рядок 2: | Рядок 2: | ||
| function p.showRandomMembers(frame) | function p.showRandomMembers(frame) | ||
|      local  |      local category = 'Учасники_спільноти_MCC'  -- Your category | ||
|      local  |      local count = 4  -- How many members to display | ||
|      local pages = mw.site |      local pages = mw.site:getCategoryMembers(category, 'all', count) | ||
|      local output = {} |      local output = {} | ||
|      for i, page in ipairs(pages) do | |||
|          table.insert(output, string.format('<p>[[%s|%s]]</p>', page.fullText, page.fullText)) | |||
|      for i  |         if i >= count then break end | ||
|          table.insert(output, string.format('<p>[[%s|%s]]</p>',  | |||
|      end |      end | ||
Версія за 22:31, 21 квітня 2024
Документацію для цього модуля можна створити у Модуль:RandomMembers/документація
local p = {}
function p.showRandomMembers(frame)
    local category = 'Учасники_спільноти_MCC'  -- Your category
    local count = 4  -- How many members to display
    local pages = mw.site:getCategoryMembers(category, 'all', count)
    local output = {}
    
    for i, page in ipairs(pages) do
        table.insert(output, string.format('<p>[[%s|%s]]</p>', page.fullText, page.fullText))
        if i >= count then break end
    end
    return table.concat(output, "\n")
end
return p