Topic on Project:Support desk

Jump to navigation Jump to search

ContactPage footer link leads to a not found (404) webpage

6
182.232.185.156 (talkcontribs)

I have an Hebrew MediaWiki 1.34.0 website with ContactPage extension with a generally default configuration;

The contact form works and I don't recall any problem with it.


I have created a footer link to the contact form via this code in LocalSettings.php:

	$wgHooks['SkinTemplateOutputPageBeforeExec'][] = function( $skin, &$template ) {
		$contactLink = Html::element( 'a', [ 'href' => $skin->msg( 'contactpage-url' )->escaped() ],
			$skin->msg( 'יצירת קשר' )->text() );
		$template->set( 'contact', $contactLink );
		$template->data['footerlinks']['places'][] = 'contact';
		return true;
	};


The created ContactPage footer link leads to a not found (404) webpage

Instead leading to:

index.php?title=מיוחד:יצירת_קשר

It leads to:

⧼contactpage-url⧽


How to solve that problem?

Bawolff (talkcontribs)
Ammarpad (talkcontribs)

You need to create the page "MediaWiki:contactpage-url" on the wiki and put the url where you want the link to redirect. Alternatively you can remove $skin->msg( 'contactpage-url' )->escaped() and replace it directly with the url. That way it's hardcoded in your LocalSettings.php

182.232.185.156 (talkcontribs)

Thank you

As suggested by @Ammarpad I have pasted the URL of the contact form webpage under a newly created webpage named:

MediaWiki:contactpage-url

This seems to redirect to the contact form just fine --- if I click the footer link I can finally navigate to the contact form.


For newcomers, I have created the new webpage by pasting this text in my website's search box and then clicked the link to create it which appeared after the message cluing that it weren't found and does not exist.

182.232.185.156 (talkcontribs)

BTW @Ammarpad the reason I chose to create a redirect instead hardcoding the link in LocalSettings.php is because Hebrew links are encoded and it makes them quite long and then I get horizontal scrolling in my text editor in LocalSettings.php and it can often be frustrating.

Bawolff (talkcontribs)

you can also use:

Title::newFromText( "hebrew page name" )->getFullUrl()

If you dont want to encode it yourself

Reply to "ContactPage footer link leads to a not found (404) webpage"