Jump to content

Module:ParentPage

From Kid Dancers Wiki
Revision as of 03:47, 30 November 2025 by Spacetrain31 (talk | contribs) (Created page with "local p = {} function p.getParent(frame) local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText local parent = pagename:match("^(.+)/[^/]+$") if parent then return parent else return "" end end function p.getParentName(frame) local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText local parent = pagename:match("^(.+)/[^/]+$") if parent then -- Remove namespace prefix for disp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:ParentPage/doc

local p = {}

function p.getParent(frame)
    local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText
    local parent = pagename:match("^(.+)/[^/]+$")
    
    if parent then
        return parent
    else
        return ""
    end
end

function p.getParentName(frame)
    local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText
    local parent = pagename:match("^(.+)/[^/]+$")
    
    if parent then
        -- Remove namespace prefix for display
        local displayName = parent:match("^[^:]+:(.+)$") or parent
        return displayName
    else
        return ""
    end
end

return p