Hello,
here is what I would like to accomplish:
somesite.net/<namespace>/<page_name[/subpage]>[?optional parameters]
Is there a way to achieve that?
Thank you and best regards,
Evgeny.
* Evgeny Fadeev evgeny.fadeev@gmail.com [Mon, 22 Feb 2010 12:23:20 -0800]:
Hello,
here is what I would like to accomplish:
somesite.net/<namespace>/<page_name[/subpage]>[?optional parameters]
Is there a way to achieve that?
Thank you and best regards,
Hi Evgeny! Take a look at the code of includes/SpecialPage.php, methods (from v1.15.1 I just use) static function executePath( &$title, $including = false ) { global $wgOut, $wgTitle, $wgRequest; wfProfileIn( __METHOD__ );
# FIXME: redirects broken due to this call $bits = explode( '/', $title->getDBkey(), 2 ); $name = $bits[0]; if( !isset( $bits[1] ) ) { // bug 2087 $par = NULL; } else { $par = $bits[1]; } ...skip... // Execute special page $profName = 'Special:' . $page->getName(); wfProfileIn( $profName ); $page->execute( $par ); $page->execute( $par ); wfProfileOut( $profName ); wfProfileOut( __METHOD__ ); return true; } That $par is a parameter after slash, passed to execute() method. If you want to build your own special page, which may take it's parameter from "slash subpage" string, you have simply to extend SpecialPage class and implement your function execute(). If you want to use such parameter somewhere else, you probably have to use Title::getSubpageText(). Request query parameters (after '?') can be obtained by using $wgRequest instance of WebRequest object methods getInt('paramname'), getCheck('paramname'), getText('paramname'). Dmitriy
On 24/02/10 8:19 PM, Dmitriy Sintsov wrote:
- Evgeny Fadeevevgeny.fadeev@gmail.com [Mon, 22 Feb 2010 12:23:20
-0800]:
Hello,
here is what I would like to accomplish:
somesite.net/<namespace>/<page_name[/subpage]>[?optional parameters]
Is there a way to achieve that?
You should do this with rewrite rules. MediaWiki expects a properly-formed MediaWiki title to come in on the 'title' GET/Post parameter. You will need to rewrite /namespace/page_name to ?title=namespace:page_name, and you will need to handle the case where there is no namespace.
Hi Evgeny! Take a look at the code of includes/SpecialPage.php, methods (from v1.15.1 I just use) static function executePath(&$title, $including = false ) { global $wgOut, $wgTitle, $wgRequest; wfProfileIn( __METHOD__ );
# FIXME: redirects broken due to this call $bits = explode( '/', $title->getDBkey(), 2 ); $name = $bits[0]; if( !isset( $bits[1] ) ) { // bug 2087 $par = NULL; } else { $par = $bits[1]; }
...skip... // Execute special page $profName = 'Special:' . $page->getName(); wfProfileIn( $profName ); $page->execute( $par ); $page->execute( $par ); wfProfileOut( $profName ); wfProfileOut( __METHOD__ ); return true; } That $par is a parameter after slash, passed to execute() method. If you want to build your own special page, which may take it's parameter from "slash subpage" string, you have simply to extend SpecialPage class and implement your function execute(). If you want to use such parameter somewhere else, you probably have to use Title::getSubpageText(). Request query parameters (after '?') can be obtained by using $wgRequest instance of WebRequest object methods getInt('paramname'), getCheck('paramname'), getText('paramname').
That doesn't sound at all what the OP is trying to do.
* Andrew Garrett agarrett@wikimedia.org [Wed, 24 Feb 2010 22:33:26 +1100]:
On 24/02/10 8:19 PM, Dmitriy Sintsov wrote:
- Evgeny Fadeevevgeny.fadeev@gmail.com [Mon, 22 Feb 2010 12:23:20
-0800]:
Hello,
here is what I would like to accomplish:
somesite.net/<namespace>/<page_name[/subpage]>[?optional
parameters]
Is there a way to achieve that?
You should do this with rewrite rules. MediaWiki expects a properly-formed MediaWiki title to come in on the 'title' GET/Post parameter. You will need to rewrite /namespace/page_name to ?title=namespace:page_name, and you will need to handle the case where there is no namespace.
He needs to distinguish the 'namespace/pagename' from 'pagename/subpage' thing. So, the main namespace probably has always to be specified in the form of 'Main/Page/Subpage'. Also, optional parameters via '?' query string doesn't make such URL's SEO-friendly. And, also, he probably has to rewrite parts of Linker, too, to generate such links from article wiki-links. Dmitriy
wikitech-l@lists.wikimedia.org