Page MenuHomePhabricator

Magic word to give Page Title as if pipe-trick performed on it
Open, LowPublicFeature


I would like a magic word which worked like {{PAGENAME}} but as if the pipe-trick had been
performed on it.

So whereas in [[John Doe (actor)]] {{PAGENAME}} would give "John Doe (actor)", I want
simply "John Doe".

This would be most useful in templates like {{imdb name}} where the result is for display
not for linking.

Possible nomenclature: {{PAGENAMEP}} together with {{PAGENAMEEP}} or {{PAGENAMEPE}}.

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:25 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz7264.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

*** Bug 7429 has been marked as a duplicate of this bug. ***

hmmm.. I don't like PAGENAMEP - but I DO like the idea. Actually, it'd be better
off as a function that went something like this:

Rewritten from bug 7429:

I'd rather suggest this forms of magic words:

Project:Foo (bar) -> Project:Foo
Project talk:Foo (bar) -> Project talk:Foo
Project talk:Foo (bar) -> Project:Foo
Project:Foo (bar) -> Project talk:Foo

conrad.irwin wrote:

Added {{pipetrick:}} in r62077

  • Bug 21994 has been marked as a duplicate of this bug. ***

{{pipetrick:}} is definitely nice, however it should be accompanied by the complement set of variables to random {{..PAGENAME(E)}} variables (see [[mw:Help:Magic words#Page_names]]), so one wouldn't have to create ugly templates with content like {{TALKPAGENAME:{{NAMESPACE}}:{{pipetrick: {{{title|{{PAGENAME}}}}}}}}} (to get {{TALKPAGENAMEP}}), which are indeed much more expensive than single variable which returns the same. Alternative (maybe even better) may be adding of |P ({{TALKPAGENAME|P}} etc.).

conrad.irwin wrote:

I've had second thoughts about changing this to #pipetrick; would it not be better to have {{PIPETRICK}} similar to {{PAGENAME}} when on it's own, and then we could couple that with {{PIPETRICKE}} (maybe this would even prompt a better choice of name :D). This would allow the features here to be implemented as:

{{DISAMBIGSUBPAGENAME}} = {{PIPETRICK}} (per recent changes)

Which I think is a little cleaner than adding an extra 12 variables and magic words.

As suggested in comment 6, you don't have to add the whole new set, just a modificator after pipe char to current set, as we did it to random other variables through the time. I would consider that as optimal - since the clearest and simpliest - solution actually.

conrad.irwin wrote:

These variables already take an argument which is the page name to act on.

{{PAGENAME:Talk:Hi}} => Hi.

It would not be hard to modify them so that {{PAGENAME:|P}} works as you propose; but {{PAGENAME|P}} would require changes to the parser (or you could just implement Template:PAGENAME {{#ifeq:{{{1|}}}|P|{{PIPETRICK}}|{{PAGENAME}}}}).

Implementation of the above 6 (really 12 with the {{PAGENAMEE:|P}} versions) cases is just a case of translating that wikitext into PHP.

The reason I WONTFIX this is because I think this syntax is ugly and confusing {{PAGENAME}} {{PAGENAMEE}} {{PAGENAME:|P}} {{PAGENAMEE:|P}} provides two totally different syntaxes for providing behavioural flags (right, we could change it to be {{PAGENAME:|E|P}} or {{PAGENAME:|EP}} or :|PE or :|P|E to make it consistent). The :| is still clearly a nasty hack, and I think people would be bitten by {{PAGENAME:P}} more often than not.

Such handling of parameters (:| combination) already exists and is being commonly used, see

conrad.irwin wrote:

They don't implicitly assume that :| == :{{PAGENAME}}|

You could do {{FULLPAGENAME:{{PAGENAME}}|P}} - I have no problem with that, but it's longer and yuckier than {{NAMESPACE}}:{{PAGENAME}}.

conrad.irwin wrote:

Ach, I'm wrong. Some of them do...

  • Bug 25313 has been marked as a duplicate of this bug. ***

This could be useful for templates.

For example, Template:PipedLink could be work as:

  • {{PipedLink|Boston}} will produce "[[Boston]]".
  • {{PipedLink|San Jose, California}} will produce "[[San Jose, California|San Jose]]"
  • {{PipedLink|Georgia (U.S. state)}} will produce "[[Georgia (U.S. state)|Georgia]]".

Instead of

state = [[Georgia (U.S. state)|Georgia]]


state = Georgia
state_link = Georgia (U.S. state)

we can put simply as

state = Georgia (U.S. state)


Now we can make this function via Lua module. But this function should be supported by MediaWiki core.

morgon.kanter wrote:

FYI for anyone that needs functionality like this, we implemented it on our wiki using plain old ParserFunctions. It's REALLY ugly and almost impossible to maintain or extend, but it works.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.