Jump to content

Template:ReturnToParent

From Kid Dancers Wiki
Revision as of 03:46, 30 November 2025 by Spacetrain31 (talk | contribs)

This template creates a link to return to the parent page.

Usage

Automatic parent detection
{{Return to parent}}
Automatically detects the parent page from the current page name.
Example: On "Paige Hyland/Gallery" it displays "Return to Paige Hyland"
Specify custom parent page
{{Return to parent|CustomPage}}
Links to the specified page instead.
Example: {{Return to parent|Main Page}}
Custom link text
{{Return to parent|parent=Help|text=Back to Help}}
Allows customizing both the parent page and the link text.

Examples

  • {{Return to parent}}
  • {{Return to parent|Help}}
  • {{Return to parent|parent=Portal:Contents|text=← Back to Contents}}

Lua Module

This template requires Module:ParentPage. Create it with the following code:

<syntaxhighlight lang="lua"> 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 </syntaxhighlight>