- weblog of Mizanur Rahman
Have you ever tried to put headers in MediaWiki and tried to edit them from page view? You might have been forwarded to template edit section instead of section edit. If you want to go to section edit section rather than template edit section then this small hack is for you.
here are the steps you have to perform:
1. open includes/Parser.php file from MediaWiki installed directory.
2. find the following line inside the formatHadings function.
# give headline the correct <h#> tag
if( $showEditLink && ( !$istemplate || $templatetitle !== “” ) ) {
if( $istemplate )
$editlink = $sk->editSectionLinkForOther($templatetitle, $templatesection);
else
$editlink = $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
} else {
$editlink = ”;
}
$head[$headlineCount] = $sk->makeHeadline( $level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink );
$headlineCount++;
if( !$istemplate )
$sectionCount++;
and replace with
if( $showEditLink && ( !$istemplate || $templatetitle !== “” ) ) {
$editlink = $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
} else {
$editlink = ”;
}
$head[$headlineCount] = $sk->makeHeadline( $level, $matches['attrib'][$headlineCount], $anchor, $headline, $editlink );
$headlineCount++;
$sectionCount++;
3. now save the file and test the feature.
you are all done to use this hack…
Trevor
March 23rd, 2008 at 12:28 am
Thank you so much for this!
Greg
August 16th, 2008 at 5:39 am
Is there any way to make this hack also jump down to the section when you click edit?
Maybe I’m doing something wrong… It allows me to click edit, but it seems to edit the whole page instead of the section.
Thanks.