Last modified: 2009-01-31 23:11:05 UTC
Now that there is a method of conveting relative paths to absolute paths, it would be nice if as an enhancements to this function could be made to allow named paths in addition to using a relative path name in order to get a absolute path name. Some examples: {{#rel2abs:Talk|Help:ParserFunction}}, will result in Help_talk:ParserFunction {{#rel2abs:Namespace|Help:ParserFunction}}, will result in Help {{#rel2abs:Talkspace|Help:ParserFunction}}, will result in Help_talk {{#rel2abs:Basename|Help:Very/Deep/Path/What/Can/We/Do}}, will result in Help:Very
If implemented, these should either be separate parser functions, or else a new base function; it isn't appropriate to extend rel2abs to perform these tasks.
I figure this is fits in with what rel2abs does. Talk pages and Namespaces are relative to the base path given, resulting in an absolute path. Basename fits in as shorthand for how ever many ../ are needed to get to the top level of the tree. None of the pages would need to exist nor any check to make sure its a valid talk page or namespace prefix.
Created attachment 2860 [details] Reimplementation of the builtin variables as a parserfunction library as rel2abs already have two parameters, it would be difficult to change it's behavior, so I though the best way was to re-implement the built in variables to be able to check on a given path instead of current title.
Looks good Carl, from looking at the attachment it seems to do what I was talking about. I just noticed possibly one subtile bug, in which basepagenamee seems to be returning the same value as basepagename.
The introduction of the {{#titleparts}} ParserFunction provides a solution for obtaining only part of the title, which was partially what I was hoping to have addressed by this proposal. If someone could add a complementary parser function to the ParserFunction extension, to obtain the namespace part, something like: {{#namespacepart:Help:ParserFunctions}} = Help then I believe this bug could be closed as fixed.
Created attachment 4110 [details] Adaptation if namespace functions in ParserFunctions Similar to the previous patch, but only things made for the namespace part of the title
This should be implemented by allowing these variables to take one parameter, the full title to evaluate on. The current implementation then becomes the 'fallback' case where there is no such value, a natural default. So {{FULLPAGENAME:Foo}} would be transparent, and {{NAMESPACE:Help:Foo}} == Help.
Created attachment 5606 [details] Patch adding core parser function versions of the various variables I couldn't get attachment 2860 [details] to work because I was forgetting to set $wgPathFunctionsUseNoPrefixHash=true, so I made this patch. It adds the functions to CoreParserFunctions.php (alongside {{ns:}}), instead of adding them as a separate extension. Other differences include: * Some calls to wfEscapeWikiText() * Correct behavior when targeting [[0]] * Correct escaping on BASEPAGENAMEE * No debugging code in NAMESPACE * Behavior when getting the talk page for a namespace where $title->canTalk() returns false. I've long wished for something like what either of these patches provides.
Functions for namespaces added in r46630.
*** Bug 17287 has been marked as a duplicate of this bug. ***
Created attachment 5759 [details] Proposed patch v1 New patch against current tree that adds FULLPAGENAME, PAGENAME, BASEPAGENAME, SUBPAGENAME, SUBJECTPAGENAME, and TALKPAGENAME.
*PAGENAME functions added in r46662
Thank you!