Jump to content

Module:ParentPage: Difference between revisions

From Kid Dancers Wiki
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..."
 
(No difference)

Latest revision as of 03:47, 30 November 2025

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