Module:Pagination
Appearance
![]() | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
Implements {{Pagination}}
Usage
For templates:
{{#invoke:Pagination|pagination}}
. Please use {{Pagination}} instead.
local p = {}
local mPagination = require('Module:Pagination')._pagination
function p.main(args)
return mPagination({prevlink="alink", nextlink="alink"})
end
return p
Parameters
- prevlink or 1
- a link for the previous button
- required: true
- nextlink or 2
- a link for the next button
- required: true
- prevstyle
- a style on how you want the previous button to look like.
- required: false
- nextstyle
- a style on how you want the next button to look like.
- required: false
Examples
- CODE
- RESULT
{{#invoke:Pagination|pagination|1=You|2=Example}}
{{#invoke:Pagination|pagination|1=You|2=Example|prevstyle=background-color: whitesmoke|nextstyle=background-color: red}}
local p = {}
local getArgs = require('Module:Arguments').getArgs
local function makeWikitextError(msg)
return error(string.format('PaginationScriptError: "%s" ([[template:Pagination#Errors|help]])', msg), 2)
end
function p.pagination(frame)
args = getArgs(frame)
prevcolor = args.prevcolor or ''
nextcolor = args.nextcolor or ''
prevlinkEL = args[1] or args.prevlink
nextlinkEL = args[2] or args.nextlink
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. prevlinkEL .. '|Previous]]</span>'
n = '<span class="next-btn" style="background-color: ' .. nextcolor .. ';>[[' .. nextlinkEL .. '|Next]]</span>'
pn = '' .. p .. ' ' .. n .. ''
if prevlinkEL and nextlinkEL == '' or nil then
return makeWikitextError('no link provided for the previous and next buttons')
else
return pn
end
end
return p