Jump to content

Module:PopularArticles: Difference between revisions

From Iskomunidad
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


function p.main(frame)
function p.main(frame)
    local category = frame.args.category or "Theses"


     local count = mw.site.stats.pagesInCategory(
     local pages = mw.ext.dpl.getPages{
         category,
         category = "Theses",
         "pages"
        ordermethod = "counter",
     )
         order = "descending",
        count = 1
     }


     return "Pages in Category:" .. category .. " = " .. tostring(count)
     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
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