3415
редагувань
| Admin (обговорення | внесок) Немає опису редагування | Admin (обговорення | внесок)  Немає опису редагування | ||
| Рядок 3: | Рядок 3: | ||
| function p.showRandomMembers(frame) | function p.showRandomMembers(frame) | ||
|      local category = 'Учасники_спільноти_MCC'  -- Your category |      local category = 'Учасники_спільноти_MCC'  -- Your category | ||
|      local  |      local results = mw.site:getCategoryMembers({ | ||
|         title = category, | |||
|         namespace = 0,      -- Assuming members are in the main namespace | |||
|         limit = 500         -- Adjust limit based on expected category size | |||
|     }) | |||
|      local output = {} |      local output = {} | ||
|      local count = 0 | |||
|     local usedIndices = {} | |||
|          table.insert(output, string.format('<p> | |||
|     -- Random selection logic | |||
|      while count < 4 and count < #results do | |||
|         local index = math.random(#results) | |||
|          if not usedIndices[index] then | |||
|             usedIndices[index] = true | |||
|             local member = results[index] | |||
|             table.insert(output, string.format('<p><a href="/wiki/%s">%s</a></p>', mw.uri.encode(member.title, 'WIKI'), member.title)) | |||
|             count = count + 1 | |||
|         end | |||
|      end |      end | ||