Topic on Project:Support desk

subpage titles : change default display

12
Nouklea (talkcontribs)

Hi,

I have been looking for an answer to that question for a while, I hope I might find help here!

I would like to modify the default title display on my Wiki in order to avoid long page names created by the use of subpages. If a page's link is a/b/c/d/e, I would like the appearing title to be only "e". I know there is a code you can add on a single page to modify the page title display, but I do not want my users to have to insert this code every time they create a subpage (the less they code, the happier they are!). So I am looking for a parameter to change withing the general settings to modify the title display.

I'm sorry but I can not give infos about the version I'm using (I just became an admin, the previous one left without giving me any infos, so I have no idea what version we are using. He installed it in december, so I believe it's not an obsolete version).

Thank you for your help!

Cavila (talkcontribs)
Ron Barker (talkcontribs)

You can find the version by clicking 'Special pages' then under 'Wiki data and tools' click on version.

Regards

Nouklea (talkcontribs)

Thanks! And so my settings is:

  • MediaWiki : 1.16.0
  • PHP : 5.3.0
  • MySQL : 5.1.36
Nouklea (talkcontribs)

If I'm right, the commands indicated by Cavila, ie $wgRestrictDisplayTitle and $wgAllowDisplayTitle give the possibility to a user to modify, on a single page, the title display. What I am looking for is a way to change the display on all pages, to show only the last section of the name and avoid listing all the parents names in the page title.

Thanks for your help!

Cavila (talkcontribs)

I'm sorry, you're right about that. Is there any good reason why those pages should be subpages? There are other, more common ways to make clear to you readers that certain pages are arranged hierarchically, e.g. through the use of categories and custom menus.

I don't know of any easy, site-wide solutions I'm afraid. An idea which may or may not work is to ensure that users add a template to subpages which includes the following line:

{{DISPLAYTITLE:{{SUBPAGENAME}}}}

(see further Help:Magic words for the two 'magic words' that are used here. Note that DISPLAYTITLE may not work with some skins.)

You can also have a look, if you haven't done so yet, at Extension:SubpageIndex and Category:Subpage extensions to see if there's anything which suits your needs.

Farinasa6 (talkcontribs)

I know this is 5 years old, but it keeps coming up in my search for how to do this. My solution was to edit the VectorTemplate.php skin. On line 117 (or wherever you can find the <h1> element with id="firstHeading" and class="firstHeading"):

   $this->html('title')

was changed to:

   echo $this->getSkin()->getTitle()->getSubpageText();

Hope this helps someone.

Toomanynights (talkcontribs)

I know this is 6 years old now, but you just have no idea how helpful you were.

Thanks a bunch, Farinasa6!

50.24.10.71 (talkcontribs)

I know this is 6 years old, but exactly would a user have to do to change it within a page? I don't want to change all pages, just one particular subpage.

Latcheenz (talkcontribs)

I know this is 2 years old since you solved this but it broke again.

@Farinasa6

Hi Farinasa6, unfortunately your code tweak does not appear to be working with v1.31.1. Any chance you could have a look?

$this->html('title')

is now

$this->get( 'title' )

Hawk914 (talkcontribs)

I found $this->getSkin()->getTitle()->getSubpageText(); still returns the complete title with paths like $this->get( 'title' )

So I think we can shorten it like:

function getShortTitle(){

$pieces = explode("/", $this->get('title'));

return end($pieces);

}
Jlenuff (talkcontribs)

I found an easy way.

Just update the ${WIKI_INSTALL_DIR}/CURRENT/skins/Vector/includes/VectorTemplate.php file by adding the following line (line 117) :

...
		$out = $skin->getOutput();
		$out->setPageTitle(Title::newFromText($out->getTitle()->getSubpageText()));
		$title = $out->getTitle();
...
Reply to "subpage titles : change default display"