Vote button trans.png
April's Project of the Month
It's spring time. It's primary election season!
Click here to find all the information you'll need to cast your ballot.




Help:DPL template transclusion

From Ballotpedia
Jump to: navigation, search

Template transclusion is a key feature of DPL's which allows you to pull information from any number of templates on a collection of pages and render it in an easy to read format on one location. As most pages within a given category contain consistent templates, this makes template transclusion a powerful tool for collecting information across a variety of sources.

Things to remember about transcluding templates are:

  • Any specific parameter from an inclusion template, i.e. {{{TEXT}}}, can be called into a DPL using that parameter name.
  • Exact code is required to include something from a template. The code is:
  • “|include = {TEMPLATE NAME}:PARAMETER1,{TEMPLATE NAME}:PARAMETER2”
  • TEMPLATE NAME: The name of the template as it is summoned on the original page from which you are pulling information.
  • PARAMETER: The name of the parameter you are summoning.
  • Commas in the above text summons two separate parameters.
  • Do not include more than one template of the same name on any page. The DPL will pull the information from both templates.

Transcluding information from templates requires a detailed knowledge of Basic template transclusion, a guide for which can be found at that link.

Transcluding whole templates

You can include an entire template by specifying the template but not specifying a parameter to include. This can be particularly useful if you are comparing templates across a number of pages for similarities and consistency. The code to include it would be the following:

Example:  Whole Template Transclusion
Code:  
{{#dpl:
|title = Richard Lugar
|ordermethod = firstedit
|include = {Polinfobox}
|format = ,[[%PAGE%]],,
}}
Description:  
Will produce a single item list including the page with the title “Richard Lugar” and incorporating the template Template:Polinfobox.
Example:  
Richard Lugar
Richard Lugar
Richard Lugar.jpg
U.S. Senate, Indiana
Retired Senator
In office
January 3, 1977-2013
PartyRepublican
Elections and appointments
Last election2006
First elected1976
Term limitsN/A
Prior offices
Mayor of Indianapolis
1968-1976
Indianapolis Board of School Commissioners
1964-1967
Education
High schoolShortridge High School (1950)
Bachelor'sDenison University (1954)
Master'sPembroke College, Oxford (1956)
Military service
Service/branchU.S. Navy
Years of service1957-1960
Personal
BirthdayApril 4, 1932
Place of birthIndianapolis, Indiana
ProfessionManufacturing Executive
ReligionMethodist
Websites
Office website
Campaign website
Richard Lugar campaign logo


Reference sections

This tool can be particularly useful for pulling the reference section on a page by pulling the reflist template from that page. When used in combination with transcluding section headings you are able to incorporate the references within those headings just below the appropriate section. However, references that are referenced early in the page and named will not appear properly.

Example:  Section and Reference transclusion
Code:  
{{#dpl:
|title = Richard Lugar
|ordermethod = firstedit
|include = #Career, {reflist}
|format = ,[[%PAGE%]],,
}}
Description:  
Will produce a single item list including the page with the title “Richard Lugar” and incorporating the section "Career" and the template Template:Reflist.
Example:  
Richard Lugar


Transcluding parts of templates

Individual portions of templates can be transcluded using the include statement and specifying both the template name and the parameter you wish to call. Note that without proper formatting, template parameters appear stacked on one another with no spacing. More formatting instructions can be found at: Help:DPL advanced formatting, section separators and Help:DPL advanced formatting, tables.

Example:  Parameter transclusion
Code:  
{{#dpl:
|title = Richard Lugar
|ordermethod = firstedit
|include = {Polinfobox}:Name,{Polinfobox}:Position
|format = ,[[%PAGE%]],,
}}
Description:  
Will produce a single item list including the page with the title “Richard Lugar” and incorporating the parameters "Name" and "Position" from the template Template:Judge infobox.
Example:  
Richard LugarRichard LugarU.S. Senate, Indiana


Transcluding from different templates

You can transclude information from different templates on the same page using the same method that you transclude two parameters from the same template.

Example:  Parameter transclusion
Code:  
{{#dpl:
|title = Richard Lugar
|ordermethod = firstedit
|include = {Polinfobox}:Name,{Congress donor box 2006}:party
|format = ,[[%PAGE%]],,
}}
Description:  
Will produce a single item list including the page with the title “Richard Lugar” and incorporating the parameters "Name" from the template Template:Polinfobox and the parameter "party" from the template Template:Congress donor box 2006.
Example:  
Richard LugarRichard LugarRepublican


Putting it all together

Example:  Multiple component transclusion with complex formatting line.
Code:  
{{#dpl:
|category = Former member, U.S. Senate
|notnamespace = Category
|count = 3
|ordermethod = firstedit
|addeditdate = true
|addauthor= true
|addpagecounter= true
|include = {Polinfobox}:Political party,%1,##.*challenge.*,{reflist}
|format = <center>This is a list of former U.S. Senators:</center><hr>,\n# [[%PAGE%{{!}}%TITLE%]],The page has %COUNT% hits and was created by %USER%. ,<br/><center>End of list.</center>
}}
Description:  
Will produce a list including the top 3 hits from the category "Former member, U.S. Senate and pulls the parameter "Political party" from the template Template:Polinfobox, the first section, all sections with "challenge" in the heading and the Template:Reflist template. It also pulls the metadata including the total number of hits and the user who started the page. The count is limited to three for convenience.
Example:  
This is a list of former U.S. Senators:

  1.  Barack ObamaDemocratic

Born on August 4, 1961, to a Kenyan father and an American mother, he spent most of his childhood and adolescent years in Honolulu, Hawaii. His parents separated when he was an infant and divorced before he turned three. At age six, he moved to Jakarta, Indonesia, where he lived with his mother and Indonesian stepfather for four years. At age ten, Obama was sent back to Hawaii to live with his grandparents. He attended Punahou Academy and graduated with honors in 1979.[1] Obama's father, Barack Obama, Sr., died in a car accident in Kenya in 1982. His mother, Ann Dunham, died of ovarian cancer in 1995.[2]

Obama graduated from Columbia University in 1983 and earned his law degree from Harvard University in 1991.[2] While interning with Sidley & Austin in 1989, he met Michelle Robinson the two began dating.[1] He helped organize voter registration drives during the Clinton campaign, lectured at the University of Chicago law school and practiced law after graduating. As a civil rights lawyer, he tried cases dealing with discrimination, voters' rights and community organizers. In 1995 he published his autobiography titled Dreams from My Father. He and Robinson married on October 3, 1992.[2]

He was elected to the Illinois Senate in 1997 and served until 2004.[3] Following an unsuccessful bid for a seat in the U.S. House of Representatives in 2000, he announced his campaign for U.S. Senate in January 2003. After winning a landslide primary victory in March 2004 to become the Democratic nominee for U.S. Senate, Obama delivered the keynote address at the Democratic National Convention in July 2004. He was elected to the U.S. Senate in November 2004 with 70% of the vote.[1]

He announced his candidacy for the United States presidency in February 2007 and defeated Hillary Clinton in the Democratic primary before defeating John McCain in the presidential election in 2008. He was sworn in as the first African-American president on January 20, 2009. Obama then ran for re-election in 2012, defeating Mitt Romney. He was sworn in for his second term on January 21, 2013.[1]

  1. Cite error: Invalid <ref> tag; no text was provided for refs named biobio
  2. Cite error: Invalid <ref> tag; no text was provided for refs named fastfacts
  3. Washington Post, "Obama Forged Political Mettle In Illinois Capitol," February 9, 2007
The page has loading... hits and was created by Kristinpedia.
  1.  Scott BrownRepublican
BallotpediaAvatar bigger (transparent background).png
The information about this individual is current as of when his or her last campaign ended. See anything that needs updating? Send a correction to our editors

Brown was born in 1959 in Kittery, Maine, and attended public high school in Wakefield, Massachusetts. He earned his B.A. from Tufts University in 1981 and his J.D. from Boston College Law School in 1985. Brown has also worked as an attorney.[1]

The page has loading... hits and was created by Chicagoist.
  1.  Kay Bailey HutchisonRepublican

Hutchison earned her B.A. and J.D. from the University of Texas. She has been a television reporter, bank executive, and businesswoman.[1]

The page has loading... hits and was created by Calebhowe.
End of list.