More languages
More actions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- Function to get the number of works using a parser function | |||
-- Function to get the number of works | |||
function p.getWorkCount(frame) | function p.getWorkCount(frame) | ||
local category = frame.args.category or '' | local category = frame.args.category or '' | ||
if category == '' then return "0 works" end | if category == '' then return "0 works" end | ||
-- | -- Use the PAGESINCATEGORY parser function | ||
local pages = frame:preprocess('{{PAGESINCATEGORY:' .. category .. '}}') | |||
local pages = | |||
-- | -- Return the result formatted | ||
local result = '' | local result = '' | ||
if tonumber(pages) == 1 then | if tonumber(pages) == 1 then | ||
Line 24: | Line 16: | ||
result = pages .. " works" | result = pages .. " works" | ||
end | end | ||
return result | return result |
Revision as of 15:05, 14 September 2024
local p = {}
-- Function to get the number of works using a parser function
function p.getWorkCount(frame)
local category = frame.args.category or ''
if category == '' then return "0 works" end
-- Use the PAGESINCATEGORY parser function
local pages = frame:preprocess('{{PAGESINCATEGORY:' .. category .. '}}')
-- Return the result formatted
local result = ''
if tonumber(pages) == 1 then
result = "1 work"
else
result = pages .. " works"
end
return result
end
function p.main(frame)
return p.getWorkCount(frame)
end
return p