Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Help:Transclusion
(section)
Help page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
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=== Using <syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME|SECTIONNAME}}</syntaxhighlight>, one can easily transclude the content within a section on one page to another by referring to the standard, ubiquitous headline-based section headers used throughout Wikipedia. To transclude the lead of an article with this method, one can use {{nowrap|<syntaxhighlight lang="wikitext" inline>{{#section-h:PAGENAME}}</syntaxhighlight>}}. This is simpler than the already widely used selective transclusion methods of the sections below, which require special source document markup. {{High priority|This selective transclusion method often adds a line break above and/or below the section transclusion, depending upon the source and target document markup; to avoid this issue, wrap the selective transclusion template in a {{tlx|trim}} template.}} In other words, use the following modifications to the transclusion code listed immediately above: * Code for transcluding a section in the body of an article: <syntaxhighlight lang="wikitext" inline>{{trim|{{#section-h:PAGENAME|SECTIONNAME}}}}</syntaxhighlight> * Code for transcluding 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)--> ====Transcluded section hatnote==== For the purpose of indicating where selectively transcluded article content is located, it is helpful to include a {{tlx|Transcluded section}} hatnote at the top of the corresponding section of the page being transcluded to; i.e., use either {{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME}}</syntaxhighlight>}} or {{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME|part=yes}}</syntaxhighlight>}}, depending upon whether the transcluded content is an entire section of the transcluding page. These templates render as follows: *{{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION}}</syntaxhighlight>}} renders as: {{transcluded section|source=PAGENAME#SECTION}} *{{nowrap|<syntaxhighlight lang="wikitext" inline>{{transcluded section|source=PAGENAME#SECTION|part=yes}}</syntaxhighlight>}} renders as: {{transcluded section|source=PAGENAME#SECTION|part=yes}} No such hatnote is needed at the section being transcluded {{em|from}}, since where else the content might appear is not of immediate interest to the reader. However, an HTML comment note between the heading and the transcluded content is probably pertinent so that editors are aware of the repurposing of the material and keep the broader audience in mind with changing the wording. Example: * <syntaxhighlight lang="wikitext" inline><!-- The content of this section is transcluded at PAGENAME2#SECTION and PAGENAME3#SECTION. --></syntaxhighlight> ===Using the labeled section method=== {{main|Help:Labeled section transclusion}} Labeled-section selective transclusion uses the [[wikipedia: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 [[wikipedia:WP:TITLE]] be independently transcludable, we edit the WP:TITLE page and enclose the "Principal Criteria" section as follows: <syntaxhighlight lang="xml+smarty"> <onlyinclude>{{#ifeq:{{{transcludesection|principalcriteria}}}|principalcriteria| ... ''(text of "Principal Criteria" section)'' ... }}</onlyinclude> </syntaxhighlight> Similarly, we enclose the "Common Name" section with: <syntaxhighlight lang="xml+smarty"> <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 [[wikipedia: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
Summary:
Please note that all contributions to Red Letter Media Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
RLMWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width