Help:Labeled Section Transclusion

From USApedia
An illustration of the scope of transclusion.

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

Extension:Labeled Section Transclusion on Mediawiki

Mediawiki's Labeled Section Transclusion contains the full range of options available with this extension.

Best practice usage within USApedia

The Labeled Section Transclusion extension provides two primary mechanisms which needed to be done in Enhanced editor (not VisualEditor) for transcluding information:

  1. 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).
  2. 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}}
YouTube
Type of businessSubsidiary
Type of site
Online video platform, Social media platform
FoundedFebruary 14, 2005; 20 years ago (2005-02-14)
Headquarters901 Cherry Avenue
San Bruno, California,
United States
Area servedWorldwide (excluding blocked countries)
OwnerGoogle LLC
IndustryVideo hosting service
ParentGoogle LLC (2006–present)
URLyoutube.com/
Content license
Uploader holds copyright (standard license);
Creative Commons can be selected.

YouTube is an American social media and online video sharing platform owned by Google. Headquartered in San Bruno, California, United States, it is the second-most visited website in the world, after Google Search. In January 2024, YouTube had more than 2.7 billion monthly active users, who collectively watched more than one billion hours of videos every day.[1] As of May 2019[update], videos were being uploaded to the platform at a rate of more than 500 hours of content per minute,[2][3] and as of 2023[update], there were approximately 14 billion videos in total.[4]

On the 9th of October 2006, YouTube was purchased by Google for $1.65 billion[5] Google expanded YouTube's business model of generating revenue from advertisements alone, to offering paid content such as movies and exclusive content produced by and for YouTube. It also offers YouTube Premium, a paid subscription option for watching content without ads. YouTube incorporated Google's AdSense program, generating more revenue for both YouTube and approved content creators. In 2023, YouTube's advertising revenue totaled $31.7 billion, a 2% increase from the $31.1 billion reported in 2022.[6] From Q4 2023 to Q3 2024, YouTube's combined revenue from advertising and subscriptions exceeded $50 billion.[7]

Since its purchase by Google, YouTube has expanded beyond the core website into mobile apps, network television, and the ability to link with other platforms. Video categories on YouTube include music videos, video clips, news, short and feature films, songs, documentaries, movie trailers, teasers, TV spots, live streams, vlogs, and more. Most content is generated by individuals, including collaborations between "YouTubers" and corporate sponsors. Established media, news, and entertainment corporations have also created and expanded their visibility to YouTube channels in order to reach greater audiences.

YouTube has had unprecedented social impact, influencing popular culture, internet trends, and creating multimillionaire celebrities. Despite its growth and success, the platform has been criticized for its facilitation of the spread of misinformation and copyrighted content, routinely violating its users' privacy, excessive censorship, promoting far-right content, endangering the safety of children and their well-being, and for its inconsistent implementation of platform guidelines.


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:

  1. Only the first occurrence of the sectionX is transcluded if you have more than one section with the same name.
  2. 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".
  3. 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}}


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:

This process uses the following templates to make it all work (we think this is all of them):

The status history for each project is maintained in a subpage. In this example, it is at Mediawikiwiki:Visual editor/status

Template:USApedia