Extension talk:HideNamespace

From mediawiki.org
Latest comment: 8 years ago by Rudloff in topic Fork

no effect[edit]

At the moment the extension isn't working for me on Mediawiki 1.15.1. I followed the directions given for installation (except HideNamespace.i18n
was renamed to HideNamespace.i18n.php because the wiki errors out otherwise). Neither the {{#hidens:}} parser or declaring namespaces to
hide with $wgHidensNamespaces have any effect. Special:Version shows the extension is registered successfully.

210.56.88.218 12:22, 1 September 2009 (UTC)Reply

I've received some reports describing the same problem. I've looked into it, but found nothing wrong. There are maybe some problems with registering the hooks, but since I can't reproduce it's difficult to fix it. --Matěj Grabovský 14:28, 1 September 2009 (UTC)Reply
Yeah I spent a while trying to trace the problem and came up empty (not real familiar with debugging MediaWiki or PHP in general). So in the meantime I've just hacked with the Mediawiki codebase a bit and made a couple of patches to strip specific NS prefixes in article pages and category listings. Thanks anyway. 210.56.88.15 15:52, 1 September 2009 (UTC)Reply
I just got a little pointer, could you please provide list of installed extensions? --Matěj Grabovský 16:18, 1 September 2009 (UTC)Reply
Just yours... I was testing it out on a fresh install of MediaWiki 1.15.1 with Xampp 1.7.1 on my local box. Only modification had been an import of an XML dump from my production wiki. 210.56.88.15 16:30, 1 September 2009 (UTC)Reply
It should work now, try the new code. --Matěj Grabovský 13:53, 2 September 2009 (UTC)Reply
You're not declaring parser functions correctly.. I had to disable function RegisterParser. See this page to see how parser functions are set up in later versions of MW Manual:Parser_functions --Frantik 10:56, 17 September 2009 (UTC)Reply
I think I'm doing it right. --Matěj Grabovský 13:46, 17 September 2009 (UTC)Reply
Unfortunately it's not working for me either. It just gives me the following error: "Internal Error. Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information." BTW I'm using MW 1.14. Regards, BradLeeBH 04:12, 25 September 2009 (UTC)Reply
It did not seem to work for me either. But it seems quite awesome, except for that. Alshgjdkjcej

This extension does nothing.

problem : Magic word 'hidens' not found[edit]

Hello, i've done everything as stated but i've this error:

Magic word 'hidens' not found

Backtrace:

  1. 0 C:\wamp\www\mediawiki\includes\MagicWord.php(244): Language->getMagic(Object(MagicWord))
  2. 1 C:\wamp\www\mediawiki\includes\MagicWord.php(197): MagicWord->load('hidens')
  3. 2 C:\wamp\www\mediawiki\includes\parser\Parser.php(4034): MagicWord::get('hidens')
  4. 3 C:\wamp\www\mediawiki\extensions\HideNamespace\HideNamespace.php(64): Parser->setFunctionHook('hidens', Array)
  5. 4 [internal function]: ExtensionHideNamespace->RegisterParser(Object(Parser))
  6. 5 C:\wamp\www\mediawiki\includes\Hooks.php(117): call_user_func_array(Array, Array)
  7. 6 C:\wamp\www\mediawiki\includes\parser\Parser.php(178): wfRunHooks('ParserFirstCall...', Array)
  8. 7 C:\wamp\www\mediawiki\includes\parser\Parser.php(190): Parser->firstCallInit()
  9. 8 C:\wamp\www\mediawiki\includes\parser\Parser.php(312): Parser->clearState()
  10. 9 C:\wamp\www\mediawiki\includes\OutputPage.php(651): Parser->parse('(Redirig?? depu...', Object(Title), Object(ParserOptions), true, true, NULL)
  11. 10 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(740): OutputPage->parse('(Redirig?? depu...', true, true)
  12. 11 C:\wamp\www\mediawiki\includes\Article.php(841): wfMsgExt('redirectedfrom', Array, '<a href="/media...')
  13. 12 C:\wamp\www\mediawiki\includes\Wiki.php(450): Article->view()
  14. 13 C:\wamp\www\mediawiki\includes\Wiki.php(63): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
  15. 14 C:\wamp\www\mediawiki\index.php(116): MediaWiki->initialize(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
  16. 15 {main}


could you help me please??

thanks for your help

What MediaWiki version are you using? --Matěj Grabovský 15:53, 2 August 2010 (UTC)Reply
Hello i use
version of Mediawiki : 1.15.4
Database : MySql 5.1.36
OS : windows xp pro 2003
PHP version : 5.2.11
serveur Apache 2.2.11
MediaWiki works on a local configuration with wampserver 2.--Eva 08:38, 6 August 2010 (UTC)Reply
Would you have an idea please?
thanks for your help
--Eva 09:46, 10 August 2010 (UTC)Reply
Sorry for the very long delay, you can now download the code for MW 1.15 through the Extension Distributor or directly from SVN. --Matěj Grabovský 14:27, 10 August 2010 (UTC)Reply
thanks it works --Eva 08:46, 11 August 2010 (UTC)Reply
You're welcome, thanks for noticing me. --Matěj Grabovský 08:37, 11 August 2010 (UTC)Reply

Error: Unsupported operand types in HideNamespace.php on line 49[edit]

First of all thanks for putting effort in this extension. It is a much anticipated one! However when I use it on my wiki (1.15.3, PHP 5.2.13, MySQL 5.0.91) and HideNamespaces version 1.4.1 it says "Fatal error: Unsupported operand types in .../public_html/okwiki/extensions/HideNamespace/HideNamespace.php on line 49".

Oddly enough, if I only activate HideNamespace.php it doesnt crash, but doesn't work either.

When I add HideNamespace.i18n.php, it doesnt crash but doesn't work either.

When I add HideNamespace.i18n.magic.php it crashes on Line 49 on above mentioned error.


Any idea what can be done? Vadra

I've update the code in SVN, it should now be available through ExtensionDistributor. --Matěj Grabovský 17:40, 26 October 2010 (UTC)Reply

For me your new code did not work. I get the error messages similar to Eva's mentioned before. What can I check/do to make it work?

What error exactly do you get? --Matěj Grabovský 16:40, 17 November 2010 (UTC)Reply

Not working in 1.16.0[edit]

As previously reported for v 1.15.X nor working for higher version. Probably the same problem.--Juan de Vojníkov 01:24, 27 November 2010 (UTC)Reply

Same for me. 87.78.238.6

A possible solution to some of the problems encountered above[edit]

As a MediaWiki newbie, forgive me if my edit is any way inappropriate.

I have just been trying to get HideNamespace working with an installation of MediaWiki 1.16.0 (+Ubuntu/PostgreSQL) but the extension was not working: no error message but namespaces were not being removed from article titles either. Then I noticed the sample code to go into the LocalSettings.php (as found under Installation) had a small mistake:

the sample code contained "wgHidensNamespaces" when it should have been "wgHideNsNamespaces"

Making this small change did the trick!!!

Franolich 21 December 2010

Thank you very much for pointing that out. It was most likely the real cause of all the troubles. I can’t believe nobody has noticed it before, you’re my hero. Thank you. —Matěj Grabovský 20:08, 21 December 2010 (UTC)Reply
GREAT Thanks for sharing this important information. I did not see this mistake! By the way I was actually looking for something different. I wanted to hide the namespace prefix on category subpages. I did find a good and working solution here: http://www.mwusers.com/forums/showthread.php?15702-How-to-hide-Category-prefix-in-my-subcategory-lists.

Happy new year!

Fascinating. Because the extension page (http://www.mediawiki.org/wiki/Extension:HideNamespace) is quite explicit that the array name is $wgHidensNamespaces, and even gives a warning saying that it was changed from $wgHideNsNamespaces in version 1.4.3. And examing the php file, the name does appear to be $wgHidensNamespaces. So unless there are two arrays, this must be an old note.
Aeric 30 Nov 2012

195.14.222.217 13:04, 31 December 2010 (UTC)Reply

Namespace removal does not work on discussion tabs[edit]

While continuing to test HideNamespace on my first MediaWiki site, I noticed that namespace removal was not working properly on discussion tabs. Specifically, only the first letter was being removed (eg. "ategory talk:Courses"). Eventually I noticed this problem only occurred when the discussion page did not already exist - as soon as I added some content all was fine.

The bug turned out to be because the ArticleViewHeader handler does not appear to be called on pages that do not exist yet (so $namespace and $namespaceL10n were left uninitialised). A solution, which I have tested, is to add a handler for the EditFormPreloadText event (there may be a better choice of event) and essentially run the same code as the ArticleViewHeader handler (with minor modifications):

...
function wfHideNamespaceSetup() {
	...
	$wgHooks['EditFormPreloadText'][] = array( &$extHidensObj, 'onEditFormPreloadText' );
	...
}
...
class ExtensionHideNamespace {
...
	function onEditFormPreloadText( &$text, &$title ) {
		self::$namespace = $title->mNamespace;

		if( self::$namespace === NS_MAIN ) {
			self::$namespaceL10n = '';
		} else {
			self::$namespaceL10n = substr( $title->getPrefixedText(), 0,
				strpos( $title->getPrefixedText(),':' ) );
		}
		return true;
	}

...
}

At the end of my testing, I discovered there are other situations where the above problem arises, eg after deleting a page the confirmation title is transformed to "ction complete". This can be remedied by checking that $namespaceL10n has been initialised in the OutputPageBeforeHTML handler:

function onBeforePageDisplay( &$out, $skin ) {
	...
	$len = strlen( self::$namespaceL10n );
	if ($len > 0) {
		$out->setPageTitle( substr( $out->getPageTitle(), $len + 1 ) );
	}
	...
}

By the way, thank you so much for a very handy extension. Without your code I would not have known where to start with developing extensions. Cheers!

Franolich 21 December 2010

I cannot reproduce this behaviour. However, try the updated version. Also, you're welcome. —Matěj Grabovský 13:36, 31 December 2010 (UTC)Reply

Problem with Magic Word "DISPLAYTITLE"[edit]

I used in some pages the DISPLAYTITLE magic word to show a different title from the default one and I notices it was cut at some point. HideNamespace cuts off the initial part of the title for as much character as the namespace is. Example: my page is titled MyNS:Title_of_the_page, with DISPLAYTITLE:My new title, it is shown "w title".

I hope this can be set up. Thank you. --Gborgonovo (talk) 13:35, 20 March 2014 (UTC)Reply

Maybe it is a solution. In the HideNamespace.php file I changes the check in the "onBeforePageDisplay" method, like this.
if( self::$hide && mb_substr( $out->getPageTitle(), 0, mb_strlen( self::$namespaceText ) + 1 )== self::$namespaceText.":" ) {
It seems to work. --Gborgonovo (talk) 13:51, 20 March 2014 (UTC)Reply

Fork[edit]

Hello,

We needed to install this extension with Composer so I am maintaining a fork here with a valid composer.json file: https://github.com/ShakePeers/mediawiki-HideNamespace

Regards,

--Rudloff (talk) 13:10, 15 January 2016 (UTC)Reply