Module:PopularArticles: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
function p.main(frame) | function p.main(frame) | ||
local | local pages = mw.ext.dpl.getPages{ | ||
category = "Theses", | |||
ordermethod = "counter", | |||
order = "descending", | |||
count = 1 | |||
} | |||
if not pages or #pages == 0 then | |||
return "No pages found." | |||
end | |||
local | local output = {} | ||
for i, page in ipairs(pages) do | |||
local title = page.prefixedText or page.title or "Unknown page" | |||
local counter = page.counter or 0 | |||
table.insert( | table.insert( | ||
output, | output, | ||
string.format( | |||
"%d. [[%s]] — %s views", | |||
i, | |||
title, | |||
mw.language.getContentLanguage():formatNum(counter) | |||
) | |||
) | ) | ||
end | end | ||
return table.concat(output, " | return table.concat(output, "\n") | ||
end | end | ||
return p | return p | ||
Latest revision as of 06:36, 2 October 2026
Documentation for this module may be created at Module:PopularArticles/doc
local p = {}
function p.main(frame)
local pages = mw.ext.dpl.getPages{
category = "Theses",
ordermethod = "counter",
order = "descending",
count = 1
}
if not pages or #pages == 0 then
return "No pages found."
end
local output = {}
for i, page in ipairs(pages) do
local title = page.prefixedText or page.title or "Unknown page"
local counter = page.counter or 0
table.insert(
output,
string.format(
"%d. [[%s]] — %s views",
i,
title,
mw.language.getContentLanguage():formatNum(counter)
)
)
end
return table.concat(output, "\n")
end
return p