Jump to content

Module:TrainingPages

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sage Ross (WMF) (talk | contribs) at 00:43, 26 March 2013 (a first try). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

--The purpose of this module is to take a list of page names and page numbers that define a module of one of the [[Wikipedia:Training]] series, and use it to determine the next and previous page to link to 


-- Return the next page, used like: {{#invoke:TrainingPages| next_page | currentpage=Wikipedia:Training/Foo/Bar | {{listofpages}} }}
function p.next_page(frame)
    local currentpage = frame.args['currentpage']
    local nextpage = 0
    for page, pagenumber in pairs(frame.args) do
        if currentpage == page then
            nextpagenumber = pagenumber + 1
        end
    end
    for page, pagenumber in pairs(frame.args) do
        if nextpagenumber == pagenumber then
            nextpage = page
        end
    end
    return nextpage
end

return p