Help:Labeled Section Transclusion
You need to use Enhanced editor, not VisualEditor when adding or editing LST. |
Labeled Section Transclusion (LST) allows you to show part of the contents of one page in one or more places across the wiki. This allows editors to maintain content in one place. If the content was copied instead of using LST, a single change to the original text could require numerous edits around the wiki to fix it in all the places it was copied.
LST is different than traditional transclusion in that allows a specific section of a page to be shown other places, rather than an entire page. In short, it is a specialized form of a template.
Documentation
|
Mediawiki's Labeled Section Transclusion contains the full range of options available with this extension.
Best practice usage within Saintapedia
The Labeled Section Transclusion extension provides two primary mechanisms which needed to be done in Enhanced editor (not VisualEditor) for transcluding information:
- Using section section heads. Examples
- {{#lsth:YouTube|Embedding videos}} will transclude the "Embedding videos" section.
- {{#lsth:YouTube}} will transclude the introduction (the info above the first section head).
- Adding section tags to relevant parts of a document. Example:
- <section begin=givethesectionaname /> what do you want to include <section end=givethesectionaname /> in the source page documents what is to be transcluded
- {{#lst:articleX|givethesectionaname}} would then be used to call that section and transclude it to the location of your choice.
The lead Gardener recommends using the section head approach to help keep the edit window as clean as possible on all related pages. This approach is not without drawbacks, namely if the section head changes, the transclusion will break, but we feel this is the most pragmatic approach.
Example: Test Transclude the intro of YouTube}
{{#lsth:YouTube}}
Basic example - {{#ev:YouTube|https://www.youtube.com/watch?v=kRphNpnQGNc|400|right|The Pontificate of John Paul II begins}} |
YouTube is a website designed for sharing videos. Users can upload, view, rate, share, add to playlists, report, comment on videos, and subscribe to other users.
YouTube's algorithm suggests videos based on user behavior, watch history, and what's trending.
Transcluding sections by headings
There is optional support for transcluding sections of text marked with the normal headings, i.e. ==this section==
. If installed, this is done with the lsth function. This is not currently enabled on wikisource or Meta.
Transclude the introduction
To transclude the introduction of a page (i.e. the content before the first heading), use
{{#lsth:pagename}}
Transclude a specific section
You can also transclude the whole content of the sectionX (which includes all its sub-sections but excludes the heading of sectionX itself).
{{#lsth:pagename|sectionX}}
Things to note:
- Only the first occurrence of the sectionX is transcluded if you have more than one section with the same name.
- Make sure you type what the heading of sectionX is in wiki code, not how it is displayed. For example if the heading of the section is
==List of [[Extension]]==
, you should type "List of [[Extension]]
" not "List of Extension
". - The matching is case insensitive, to prevent links from breaking due to case changes.
Transclude multiple sections
You can also transclude from the first occurrence of sectionX (excluding the heading of sectionX itself) until it reaches the next occurrence of sectionY. Note that sectionY acts as a stop point so the transclusion doesn't contain the content of sectionY.
{{#lsth:pagename|sectionX|sectionY}}
Explicitly marking content to be transcluded
Step 1: Mark off sections
Mark off sections in the text using <section> tags like this:
<section begin=chapter1 />this is a chapter<section end=chapter1 />
Note that this uses two individual markers, rather than normal XML open/close tags, which simplifies nested or overlapping sections. This allows you to insert section tags without worrying about interfering with other sections.
Step 2a: Transclude the section
Call the parser function #lst to transclude it, i.e. to transclude a section called chapter1 from a page called articleX:
{{#lst:articleX|chapter1}}
The target article defines the location of the section; its behavior is determined by the parser function.
Step 2b: Transclude the page but excluding the section
To transclude a page, but exclude a specified section, use the #lstx function:
{{#lstx:articleX|chapter1}}
Optionally, you may add replacement text to the excluded section.
{{#lstx:articleX|chapter1|replacement_text}}
Example:
{{#lstx:articleX|chapter1|See chapter 1 in [[articleX]].}}
The replacement text will appear in the area where the section is skipped (excluded).
Example: Transclude a specific section of YouTube
{{#lsth:YouTube|Embedding videos}}
To embed a YouTube video....
https://www.mediawiki.org/wiki/Extension:EmbedVideo_(fork)
Limitations
Labeled Section Transclusion appears to ignore noinclude (<noinclude></noinclude>
). Please keep this in mind when using it.
External links
Example uses on other wikis
The Wikimedia foundation is using this function to create an elegant process for status updates. See:
- Mediawikiwiki:Visual editor as an example of tracking status (see its status page).
This process uses the following templates to make it all work (we think this is all of them):
- Mediawikiwiki:Template:Wikimedia project status line
- Mediawikiwiki:Template:Wikimedia project status line/blue link
- Mediawikiwiki:Template:Wikimedia project status line/red link
- Mediawikiwiki:Template:LST section begin
- Mediawikiwiki:Template:close tag
- Mediawikiwiki:Template:LST section end
- Mediawikiwiki:Template:close tag
The status history for each project is maintained in a subpage. In this example, it is at Mediawikiwiki:Visual editor/status