Page MenuHomePhabricator

Introduce a new Variable {{ROOTPAGENAME}} (similar to {{BASEPAGENAME}}
Closed, ResolvedPublic

Description

Author: mediazilla

Description:
Hello,

i hope that it is okay to request new features here in MediaZilla like it is done in other huge projects using
bugzilla too. I would not know where else to put it.

It's just a small thing that should be fast implemented. It is about the Variables regarding the Pagename which is
important for writing dynamic templates. My idea is to introduce a Variable Names ROOTPAGENAME which has similar
content like BASEPAGENAME. ROOTPAGENAME should only contain the name of the topmost page without namespace, e.g.
for "User:Name/Article/Subarticle" it should be "Name". BASEPAGENAME would be "Name/Article" here.

For those of you who think that this is not necessary to implement this let me show you a little example for what this
is good for:

Recently i wanted to change a Template in our german wikipedia, Named Vorlage:Archiv. This is a template which can be
included into archived-discussion pages. It is very common to store those archives in subpages. For example For
wikipedia:de:Internetforum there are archives in wikipedia:de:Internetforum/Archiv/Diskussionsforum and
wikipedia:de:Internetforum/Archiv/Webforum (this is because there were two articles once which have been combined in
that new article and the old discussion-pages have been moved there). Similarily the heavy discussions on Mainpages
are often moved to Mainpage/archive/date . I wanted to introduce a dynamic link into that template which point to the
current discussion. If i used [[Discussion:{{BASEPAGENAME}}]] than it would point to a wrong page which does not
exist. Here [[Discussion:{{ROOTPAGENAME}}]] would be needed.

greetings and the best wishes, Warhog


Version: 1.22.0
Severity: enhancement

Details

Reference
bz6747

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 9:18 PM
bzimport set Reference to bz6747.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Jul 19 2006, 9:18 PM

robchur wrote:

You can use the {{#titleparts}} parser function to obtain this.

#titleparts requires the installation of an additional extension just to work.

BASEPAGENAME is a misnomer and we should have had ROOTPAGENAME inside core a long time ago.

I see absolutely no reason to not include such a simple and basic magic word inside of core.

If someone wants to do this, it should be easy enough.

The Title object already has a "getRootText()" method that does exactly what you want, so you can just copy the code for {{BASEPAGENAME}} and change the call to "getBaseText()" to "getRootText()".

Look for "basepagename" in includes/parser/CoreParserFunctions.php, includes/parser/Parser.php, includes/MagicWord.php, and languages/messages/MessagesEn.php.

Then look for "BASEPAGENAME" in tests/parser/parserTests.txt and maintenance/fuzz-tester.php.

Then add mention in RELEASE-NOTES-1.21 (or whatever version we're up to once someone gets around to this), stick it in Gerrit, and add me as a reviewer.

(In reply to comment #2)

BASEPAGENAME is a misnomer

Why shouldn't "Foo/Bar/Baz" be considered the base of "Foo/Bar/Baz/Quux"?

I see absolutely no reason to not include such a simple and basic magic word
inside of core.

So do it then.

(In reply to comment #3)

(In reply to comment #2)

BASEPAGENAME is a misnomer

Why shouldn't "Foo/Bar/Baz" be considered the base of "Foo/Bar/Baz/Quux"?

I see absolutely no reason to not include such a simple and basic magic word
inside of core.

So do it then.

I have a bunch of changesets that need my attention and haven't had any time to work on MW stuff lately.

Related URL: https://gerrit.wikimedia.org/r/60198 (Gerrit Change I71ef0a15c95c9145462f3aa7fdb3ed11dac79265)

(In reply to comment #5)

Related URL: https://gerrit.wikimedia.org/r/60198 (Gerrit Change
I71ef0a15c95c9145462f3aa7fdb3ed11dac79265)

Status Merged