Module:Pagination: Difference between revisions
Appearance
Content deleted Content added
Fixed |
In accordance with the code at simple english wiki |
||
Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
local function makeWikitextError(msg) |
|||
⚫ | |||
end |
|||
function p.pagination(frame) |
function p.pagination(frame) |
||
args = frame.args |
args = frame.args |
||
Line 6: | Line 9: | ||
previous = args[1] or args.previous |
previous = args[1] or args.previous |
||
nextEl = args[2] or args.next |
nextEl = args[2] or args.next |
||
msg = { |
|||
nopreviousLink = 'no link for the previous button ([[template:Pagination#Errors|help]])', |
|||
nonextLink = 'no link for the next button ([[template:Pagination#Errors|help]])', |
|||
noLink = 'no link for both the previous and next buttons ([[template:Pagination#Errors|help]])' |
|||
} |
|||
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>' |
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>' |
||
n = '<span class="next-btn" style="background-color: ' .. nextcolor .. ';>[[' .. nextEl .. '|Next]]</span>' |
n = '<span class="next-btn" style="background-color: ' .. nextcolor .. ';>[[' .. nextEl .. '|Next]]</span>' |
||
pn = '' .. p .. ' ' .. n .. '' |
pn = '' .. p .. ' ' .. n .. '' |
||
if previous |
if previous and nextEl == '' or nil then |
||
return makeWikitextError('no link provided for the previous and next buttons') |
|||
⚫ | |||
else |
else |
||
return pn |
return pn |
Latest revision as of 15:58, 1 June 2025
![]() | 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
[edit]{{#invoke:Pagination|pagination}}
local p = {}
local function makeWikitextError(msg)
return error(string.format('PaginationScriptError: "%s" ([[template:Pagination#Errors|help]])', msg), 2)
end
function p.pagination(frame)
args = frame.args
prevcolor = args.prevcolor or ''
nextcolor = args.nextcolor or ''
previous = args[1] or args.previous
nextEl = args[2] or args.next
p = '<span class="prev-btn" style="background-color: ' .. prevcolor .. ';>[[' .. previous .. '|Previous]]</span>'
n = '<span class="next-btn" style="background-color: ' .. nextcolor .. ';>[[' .. nextEl .. '|Next]]</span>'
pn = '' .. p .. ' ' .. n .. ''
if previous and nextEl == '' or nil then
return makeWikitextError('no link provided for the previous and next buttons')
else
return pn
end
end
return p