Template:SubPage2 View history

(updated)
(typo)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#ifeq: {{#titleparts:{{{1|{{PAGENAME}}}}}|1|1}}| USA<!-- If USA template page -->
{{#ifeq: {{#titleparts:{{{1|{{PAGENAME}}}}}|1|1}}| USA<!-- If USA template page -->
   | {{#titleparts:{{{1|{{PAGENAME}}}}}||3}}<!-- Return all after "USA/xxxxx"-->
   | {{#ifeq: {{#titleparts:{{{1|{{PAGENAME}}}}}|1|2}}| CommonState<!-- If template -->
      | {{#titleparts:{{{1|{{PAGENAME}}}}}|1|3}}<!-- Ret 1 after "USA/CommonState"-->
      | {{#ifeq: {{padright:|4|{{#titleparts:{{{1|{{PAGENAME}}}}}|1|3}}}}|Test<!-- If 3nd level = "Test..." -->
          | {{#titleparts:{{{1|{{PAGENAME}}}}}|1|4}}<!-- Return 4th level only -->
          | {{#titleparts:{{{1|{{PAGENAME}}}}}|1|3}}<!-- Else return 3rd level -->
        }}<!-- End ifeq Test-->
    }}<!-- End ifeq CommonState -->
   | {{#ifeq: {{padright:|4|{{#titleparts:{{{1|{{PAGENAME}}}}}|1|2}}}}|Test<!-- If 2nd level = "Test..." -->
   | {{#ifeq: {{padright:|4|{{#titleparts:{{{1|{{PAGENAME}}}}}|1|2}}}}|Test<!-- If 2nd level = "Test..." -->
       | {{#titleparts:{{{1|{{PAGENAME}}}}}||3}}<!-- Return all after 2nd levels -->
       | {{#titleparts:{{{1|{{PAGENAME}}}}}|1|3}}<!-- Return 3rd level only -->
       | {{#titleparts:{{{1|{{PAGENAME}}}}}|2|2}}<!-- Else return 2nd level only -->
       | {{#titleparts:{{{1|{{PAGENAME}}}}}|1|2}}<!-- Else return 2nd level -->
    }}
    }}<!-- End ifeq non-CommonState pages -->
}}<noinclude>{{documentation|Template:RootPage/doc}}</noinclude>
}}<noinclude>{{documentation|Template:RootPage/doc}}</noinclude>

Latest revision as of 15:34, 25 July 2014

Documentation icon Template documentation[view] [edit] [history] [purge]

This template uses the #titleparts parser function extension to extract only the root of the page name.

Usage

Place {{RootPage}} where the root of the current page name is desired. An optional parameter is a pagename other than the current pagename.

Pagename {{RootPage}}
USA/CommonState/Test USA
USA USA

Related versions

{{RootPage2}}
An adaptation of {{RootPage}} except if the root page is USA it uses the second subpage. This enables the automation of USA/CommonState template suite to display the state or region name on pages and the template itself will display CommonState. It is like a template to obtain the state or territory name for other templates.
{{BasePage2}}
It operates half way between {{RootPage2}} and {{BASEPAGENAME}}. It is highly customized for the USA/CommonState template suite. The pages with "USA/CommonState" respond with USA/CommonState, but all other pages return the primary pagename of BasePageName or BasePageName/Test... (and exclude USA for regions). This enables the automation of USA/CommonState to display normally if it is deployed on test pages. The state or region page can then be tested without affecting the original page and after testing is complete it can be moved along with all the subpages to the primary page. This function requires test pages only start from a subpage that begins /Test... below the initial page name for the state or territory. This also means no other section be created as a subpage that begins with /Test....
Page name Intent Condition
California/Test Main test page for a new California template Good
California/Test city
California/Testimonials
A custom section to link from other current pages Bad. This page will cause link failures if {{BasePage2}} is used on that page.
{{SubPage2}}
Like BasePage2 it is highly customized for the USA/CommonState template suite. On pages with USA/CommonState, it will display the primary/initial subpage (if present), which serves as the section page name, otherwise it is blank. For all other pages, it returns the first subpage after BasePage2.


Pagename {{RootPage2}} {{BasePage2}} {{SubPage2}}
USA/CommonState/Test CommonState USA/CommonState Test
USA/CommonState CommonState USA/CommonState
USA/CommonState/Test/Test 2 CommonState USA/CommonState Test
USA/Southeast/Test/Test 2 Southeast USA/Southeast/Test Test 2
USA/Southeast/Test 2 Southeast USA/Southeast/Test 2
USA/Southeast/To do Southeast USA/Southeast To do
Arizona/To do Arizona Arizona To do
Arizona/Test/To do Arizona Arizona/Test To do
Arizona/Test Arizona Arizona/Test
Arizona/Test/To do/Main Arizona Arizona/Test To do
District of Columbia/Test/To do/Main District of Columbia District of Columbia/Test To do
Arizona/Test/To do/Main/Preload Arizona Arizona/Test To do
District of Columbia/Test/To do/Main/Preload District of Columbia District of Columbia/Test To do
Arizona/To do/Main/Preload Arizona Arizona To do
Arizona/Testing/To do/Main/Preload Arizona Arizona/Testing To do
Arizona/Testing/To do/Preload Arizona Arizona/Testing To do
The above documentation is transcluded from Template:RootPage/doc.
Subpages of this template.