Mediawiki 1.16: labeled section transclusion
We have installed the Labeled section transclusion extension which basically allows you to transclude particular sections from another page or explicitly mark off a portion of the page to be transcluded.
I've been using #lsth to transclude headers, but have noted that it doesn't include the section header itself, which means the "Edit" link to the section isn't there.
Now I could always explicitly write an edit link to that section, but if I hardcode the section number and add more sections to the source page, the edit links would point to the wrong sections.
Is there a way to get the Edit link to the transcluded section?
Here is an example: I have a News page th开发者_运维技巧at will list all sorts of general happenings that occurs on the wiki. It consists of "project news" and "administrative news", and some other categories.
They will be used in many places, so it's easiest to transclude them. I didn't want to create separate pages for each type of news, so I decided to use section transclusion. However, if a user wanted to update the news, there is no convenient way to click on an EDIT link that goes straight to the section.
I tried this with the following:
test is
==hi!==
Original is
==1==
{{test}}
==2==
It renders as:
==1==
==hi!==
==2==
So, this must be a problem with the extension, not with the transclusion mechanism. Make sense to you?
Don't transclude the header, transclude the whole section including the header by putting LST tag from before the header till the end of the section.
When you use a section as a transclusion container in LST, it removes the header intentionally; I suspect that this is so you can easily label a bunch of transcludable text on a page with purely organizational headers (like numbered sections) without worrying about them showing up. So in your case, instead of using the {{#lsth}
function, you'll have to use the slightly more complicated {{#lst}}
function. Wrap the whole section in <section begin/><section end/>
tags, including the header, and then it will transclude properly. For example:
<section begin="mySection" />
== My Section ==
My long block of text.
<section end="mySection" />
Then simply place a {{#lst:myPage|mySection}}
function on the page where you want it to appear, and the header (and edit block) will come with it.
Alternatively, use an embedded level of headers. If you have this page:
== My Transclusion ==
=== My Section ===
My block of text
== My Second Transclusion ==
And you use a {{#lsth:myPage|My Transclusion}}
function, it will transclude everything until the next header of the same level (My Second Transclusion, in this case), including the "My Section" header. If you want My Section to be a normal (<h2>
) header, then do this:
= My Transclusion =
== My Section ==
My block of text
= My Second Transclusion =
精彩评论