Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Help:Transclusion
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Selective transclusion== {{shortcut|WP:SELECTIVETRANSCLUSION|WP:SELTRANS}} {{See also|Template:Excerpt|Template:Transcluded section}} ''Selective transclusion'' is the process of [[#Partial transclusion|partially transcluding]] one selected section of a document that has more than one transcludable section. As noted above, if only one section of a document is to be transcluded, this can be done by simply surrounding the section of interest with <syntaxhighlight lang="wikitext" inline><onlyinclude> β¦ </onlyinclude></syntaxhighlight> tags, and transcluding the whole page. However, to selectively transclude one section from a template or document into one page, and another section from the same template or document into a second page and/or a different section of the same page, requires a way to: :a) uniquely mark each transcludable section in the source document; and :b) in the target document(s) (those to show the transcluded sections), a way to specify which section is to be transcluded. This section describes how to accomplish this. There are three ways of doing this: (1) Section header-based transclusion, (2) Labeled section transclusion, and (3) the parametrization method. ===Standard section transclusion=== {{notice|text='''This method may cause line break insertion:''' Standard section transclusion may introduce a leading or trailing [[Line break (computing)|line break]] or newline, depending on the markup in the source and target pages. To prevent this, [[Wikipedia:Wrapper templates|wrap]] the transclusion code in a {{tlc|trim}} template. See [[#prevent line break insertion|examples below]].}} Standard section transclusion uses <syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME|SECTIONNAME}}</syntaxhighlight>. One can easily transclude the content within a section from one page to another using the ubiquitous headline-based [[Help:Section|section headers]] used throughout Wikipedia. To transclude the [[Wikipedia:Lead|lead]] section of an article with this method, one can use {{nowrap|<syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME}}</syntaxhighlight>}}. This method is simpler than other selective transclusion methods, which require special [[Wikipedia:Markup|markup]] in the source article or page to specify what content should be included or excluded. {{anchor|prevent line break insertion}}Standard section transclusion may introduce a leading or trailing [[Line break (computing)|line break]] or newline, depending on the markup in the source and target pages. To prevent this, [[Wikipedia:Wrapper templates|wrap]] the transclusion code in a {{tlx|trim}} template. For example: * To transclude the section of an article: <syntaxhighlight lang="wikitext" inline>{{trim|{{#section-h:PAGENAME|SECTIONNAME}}}}</syntaxhighlight> * To transclude the lead of an article: <syntaxhighlight lang="wikitext" inline>{{trim|{{#section-h:PAGENAME}}}}</syntaxhighlight> <!-- This warrants expansion (better formatting, examples), but I'm creating the section for now - to see what the initial feeback is. -Elvey)--> ====Hatnote on the target page==== To indicate on the {{em|target page}} where selectively transcluded content originates (its source), a {{tlx|Transcluded section}} [[Wikipedia:Hatnote|hatnote]] must be placed at the top of the corresponding section in the {{em|target page}} where the content is being transcluded {{em|to}}.{{refn|group=lower-alpha|No hatnote should be placed on the {{em|source page}}, in other words no hatnote is needed on the page being transcluded {{em|from}}, as readers do not need to know where else the content appears.}}{{refn|group=lower-alpha|That is the hatnote should be placed below the header but above the content, per [[MOS:Layout]].}} Use either of the following, depending on whether the transcluded content is the entire section or only part of it: * If an entire section in the target page is transcluded the source: <syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION}}</syntaxhighlight>, which renders as: :{{transcluded section|source=PAGENAME#SECTION}} * If only part of a section in the target page is transcluded the source, specify {{para|part|yes}}: <syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION|part=yes}}</syntaxhighlight>, which renders as: :{{transcluded section|source=PAGENAME#SECTION|part=yes}} ====Hidden comment on the source page==== It is recommended to include a [[Wikipedia:Manual of Style/Hidden text|hidden comment]] at the beginning of the transcluded section in the {{em|source page}}. This comment informs editors that the content is being used elsewhere and serves as a reminder to consider the broader audience when modifying the wording. Additionally, it helps maintain the integrity of the transcluded material on the target page. For example (replace {{mono|<nowiki>[[PAGENAME#SECTION]]</nowiki>}} with the name of the target page): {{Talk quote block minimalist|{{Example HTML comment|The content of this section is transcluded to <syntaxhighlight lang="wikitext" inline>[[PAGENAME#SECTION]]</syntaxhighlight>. Please be aware that changes made to the original source here will affect the transcluded version on the target page mentioned.}}}} '''No hatnote should be placed on the {{em|source page}}''', in other words no hatnote is needed on the page being transcluded {{em|from}}, as readers do not need to know where else the content appears. ===Using the labeled section method=== {{main|Help:Labeled section transclusion}} Labeled-section selective transclusion uses the [[WP:PF|parser function]]s listed in [[mw:Extension:Labeled Section Transclusion]], which are enabled on all Wikimedia wikis, to selectively transclude content. See [[Help:Labeled section transclusion]] for how labeled section transclusion works. ===Parametrization method=== =====Source document markup===== Insert the following line into the "source" document (the one from which text is to be transcluded), immediately preceding the first line of each section to be transcluded, substituting SECTIONNAME (twice) with the unique name of the respective section. The section name can be any identifier and must be unique within that document: :<syntaxhighlight lang="wikitext" inline><onlyinclude>{{#ifeq:{{{transcludesection|SECTIONNAME}}}|SECTIONNAME|</syntaxhighlight> End each such transcludable section with: :<syntaxhighlight lang="wikitext" inline>}}</onlyinclude></syntaxhighlight> =====Target document markup===== To transclude a section marked as above into another page (the "target page"), use the following line on that page, substituting PAGENAME for the "source" document from which text to be transcluded, and SECTIONNAME with the name of the section you want to transclude: :<syntaxhighlight lang="wikitext" inline>{{PAGENAME|transcludesection=SECTIONNAME}}</syntaxhighlight> Thus each section enclosed within <syntaxhighlight lang="wikitext" inline><onlyinclude> β¦ </onlyinclude> </syntaxhighlight> tags will always be rendered when the <code>transcludesection</code> parameter is not set (when the document is viewed ordinarily, or when the document is transcluded without setting the <code>transcludesection</code> parameter as shown below), and will be rendered by transclusion on any page that does set <code>transcludesection</code> to the section's name. It will ''not'' be rendered by transclusion that uses the <code>transcludesection</code> parameter but sets it to anything other than the name of the section. Also, when providing PAGENAME, without providing a [[Wikipedia:Namespace|Namespace]], the wiki will assume that the PAGENAME belongs in the [[Wikipedia:Template_namespace|Template Namespace]]. To transclude from a [[Wikipedia:Main_namespace|Mainspace]] article, use :PAGENAME. :<syntaxhighlight lang="wikitext" inline>{{:PAGENAME|transcludesection=SECTIONNAME}}</syntaxhighlight> =====Example===== If we want to make the "Principal Criteria" and "Common Name" sections of [[WP:TITLE]] be independently transcludable, we edit the WP:TITLE page and enclose the "Principal Criteria" section as follows: <syntaxhighlight lang="wikitext"> <onlyinclude>{{#ifeq:{{{transcludesection|principalcriteria}}}|principalcriteria| ... ''(text of "Principal Criteria" section)'' ... }}</onlyinclude> </syntaxhighlight> Similarly, we enclose the "Common Name" section with: <syntaxhighlight lang="wikitext"> <onlyinclude>{{#ifeq:{{{transcludesection|commonname}}}|commonname| ... ''(text of "Common Name" section)'' ... }}</onlyinclude> </syntaxhighlight> Then, to transclude the "Principal Criteria" section into another page, we insert into that page: :<syntaxhighlight lang="wikitext" inline>{{WP:TITLE|transcludesection=principalcriteria}}</syntaxhighlight> To transclude the "Common Name" section into another page, we insert into that page: :<syntaxhighlight lang="wikitext" inline>{{WP:TITLE|transcludesection=commonname}}</syntaxhighlight> Of course, the same page can transclude two or more sections this way by including multiple such lines. There is no limit to how many selectable sections for transclusion a document can have. The only requirement is that each <code>transcludesection</code> be given a value that is unique within that page. =====Additional markup for selectively transcluded sub-article leads===== {{further|Wikipedia:Summary style#Using excerpts for article synchronization}} Per [[MOS:LEAD#Format of the first sentence]], the first instance of the sub-article title should appear in bold in the first lead sentence of that article; this is often not desirable for a transclusion to a section of the parent article. In addition, the parent article is often wikilinked in the lead of a sub-article; when transcluded to the parent article, this wikilink will appear as bold text. The wikitext markup listed below can be used to address both of these problems. To ensure that the article title is bolded in the first sentence of the sub-article, but unbolded and wikilinked in the transclusion to the parent article, make the following replacement in the sub-article's first lead sentence: :Replace ::<code>'''{{var|SUB-ARTICLE_PAGENAME}}'''</code> :with ::<syntaxhighlight lang="wikitext" inline><noinclude>'''</noinclude>{{No selflink|{{var|SUB-ARTICLE_PAGENAME}}}}<noinclude>'''</noinclude></syntaxhighlight> If there is a wikilink to the parent article in the lead section of the sub-article, replacing the wikilink to the parent article with a {{tlx|no selflink}} template will ensure that it is wikilinked in the sub-article's lead but not in the transclusion to the parent article. In other words: # If the wikilink to the parent article is not a [[WP:Piped link]], replace <code>[[{{var|PARENT_ARTICLE}}]]</code> with {{tnull|no selflink|{{var|PARENT_ARTICLE}}}} in the sub-article's lead # If the [[Wikipedia:Piped link|wikilink to the parent article includes a pipe (e.g., this link)]], replace <code>[[{{var|PARENT_ARTICLE}}|{{var|Piped link wikitext}}]]</code> with {{tnull|No selflink|{{var|PARENT_ARTICLE}}|{{var|Piped link wikitext}}}} in the sub-article's lead
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)