FANDOM


local p = {}
function p.exists(frame)
    local sPage = frame.args[1]
    if sPage then 
        local num = frame:preprocess('{{:'..sPage..'}}')
        if string.sub(num,1,3) ~="[[:"  then
            -- page exists. output the second parameter or the named parameter "true"
            return frame.args[2] or frame.args["true"]
        end
    end
    -- page does not exists. output the third parameter or the named parameter "false"
    return frame.args[3] or frame.args["false"]
end
 
function p.existsSlow(frame)
    local tArgs = frame:getParent()
    if not(tArgs.args[1]) then
        tArgs = frame
    end
 
    local sText = tArgs.args[1]
 
    if sText and sText ~= "" then
        if  mw.title.new( sText ).exists then
            -- page exists. output the second parameter or the named parameter "true"
            return tArgs.args[2] or tArgs.args["true"]
        else 
            -- page does not exists. output the third parameter or the named parameter "false"
            return tArgs.args[3] or tArgs.args["false"]
        end
    end
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.