Topic on Project:Support desk

How to remove braces from {contactpage-url}?

18
182.232.185.156 (talkcontribs)

In an Hebrew MediaWiki 1.34.0 I have an all default ContactPage.

By the following code I have added a footer link which is aimed to link to the only contact form I have:

	$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;
	};

This adds a footer link with the following link text:

{יצירת קשר}

Why are the braces ({}) wrapping it are there and how to remove them backendly?

How to remove braces from {contactpage-url}?

I can remove the braces with JavaScript but I don't want to do that.

Bawolff (talkcontribs)

same answer as your other question

182.232.185.156 (talkcontribs)

@Bawolff I have asked several different focal questions to ensure modularity and good SEO for people myself who are not PHP programmers and are stuck with these situations.

You might want to be more specific about which answer you refer to.

Bawolff (talkcontribs)

That's not really my concern. You asked almost literally the same question twice within an hour of each other.

182.232.185.156 (talkcontribs)

I personally don't think that a question about how to fix a dead link and how to remove angle brackets are almost literally the same.

182.232.185.156 (talkcontribs)

I think that "an automatically created broken link" is a better definition than "dead link" in this case.

182.232.185.156 (talkcontribs)

I think I know now (I just checked my other recent thread)

Ammarpad (talkcontribs)

These are not braces, they're angle brackets. There are two ways to fix this, mostly similar with the url issue above. You can remove $skin->msg( 'יצירת קשר' )->text() directly and hardcode the label string.

If you choose that, together with the url, the contatclink line should become $contactLink = Html::element( 'a', [ 'href' => 'you-link-target' ], 'יצירת קשר' );

The other option is to manage it from the wiki interface. In that case you need to change the label message to something like $skin->msg( 'contactpage-label' )->text(), and after that create a page "MediaWiki:contactpage-label" on the wiki and put the Hebrew label there.

182.232.185.156 (talkcontribs)

@Ammarpad because I fixed the 404 by creating a webpage whom redirects to the contact form (as you have suggested here), I think I should take the second option you presented, that is, to remove these angle brackets from the wiki interface,

But where could I control which content, if all, wraps information structures such as the footer ContactPage link?

182.232.185.156 (talkcontribs)

which content, if at all *

TiltedCerebellum (talkcontribs)
182.232.4.39 (talkcontribs)

@TiltedCerebellum I don't think so; although I am not a PHP programmer, I generally work all-core and this is a minor appearance problem.

I thought I found a JavaScript solution:

const [...elements] = document.getElementsByTagName("*");
elements.forEach((element) => {
    if (element.textContent == "⧼יצירת קשר⧽") {
        element.textContent = "יצירת קשר";
    }
});

Executing it in Chrome console deletes the angle brackets, but the hyperlink gets broken; someone knows why?

Bawolff (talkcontribs)

because you are editing the text content of a node that contains non-text content (a link), so all the non-text content gets removed to allow setting the text-only content. https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

You should stop doing things you dont understand and spend a little time reading about what the stuff you are doing actually does. The brackets literally only appear because you added extra code to add them. We're not here to explain why every random piece of code you copy and paste doesn't work. We're here to link to documentation and help fill in the gaps after you have tried to figure it out by yourself.

TiltedCerebellum (talkcontribs)

What my response was saying is that you have 5-6 questions now all relating to hook use in less than 3 days (4 of which are on the same topic), which are for extending mediawiki (i.e., not built-in so not an issue with MediaWiki out of the box), so you might consider using one of the Professional development and consulting contacts to get help with customizing mediawiki via hooks. The MW help desk is not obligated in any way to help with customization although they will be kind enough to point you to places in the manual where you can learn to do it yourself. They are unlikely to give you working customization code, so you are likely better off using a name from the professional development and consulting link than to continue making repeated threads for the same/similar issues.

Also they don't appreciate multiple related threads, this makes their job harder. Typically they like you to keep related topics in a single thread.

These appear to be your separate help threads over the last 3 days:

Topic:Vr7vy8dfi6lopv8l This thread How to remove braces from {contactpage-url}? (hooks) - 19 mins ago

Topic:Vqzvrglya6s8mfud How to edit the footer menu when working with default skins? (hooks) - 7 hours ago

Topic:Vr7yzqbnp11bdxqx ContactPage footer link leads to a not found (404) webpage (hooks) - 15 hours ago

Topic:Vr28yxdj94qtlskf How to delete a default footer link in MediaWiki >=1.35.0? (hooks) - 20 hours ago

Topic:Vr398817s5j1oo97 How to change footer menu ⧼contactpage-label⧽ text AND link-address? (extension) - 21 hours ago

Topic:Vr34jvqzkodq6688 How to add a default footer link in MediaWiki >=1.35.0 (hooks) - 2 days ago


Simply adding a comment to one of your existing threads would have bumped it back up to the top. You don't need to go creating a new one for each way you reword the same topic. Search would still find them. Duplicate topics or topics continued in separate posts are annoying to helpers here and generally discouraged.

The extension used to create this page--Structured Discussion/Flow--creates a separate mediawiki page for every topic created. Please try to avoid duplicates, near duplicates or the continuation of a previous recent discussion in a new comment. Creating all of those extra pages is unnecessary.

182.232.4.39 (talkcontribs)

@TiltedCerebellum I think that generally each one of the linked posts is good besides How to change footer menu ⧼contactpage-label⧽ text AND link-address? as besides that one, they all relate to different problems with the current footer menu to which I found the manual often messy and unclear.

I had not intention to create anymore posts.

That said, you didn't reply about the problem I have presented where textContent changes break the footer menu link sadly; I don't know if it would be better for me to copy it to a new post here, or into another thread.

182.232.171.234 (talkcontribs)

Regarding the JavaScript I published above,

Instead of textContent or innerText, I should have used innerHTML

This can be confusing sometimes.

I checked it both from console and from מדיה ויקי:Common.js in latest Google Chrome.

I also checked it from latest Microsoft Edge after the change in מדיה ויקי:Common.js was made.

Bawolff (talkcontribs)

really you shouldn't do either because it will make your web browser slow on long pages and the only reason the brackets are there is because the original code you posted called skin->msg when it makes no sense to

182.232.171.234 (talkcontribs)

I also had to translate the JavaScript code to ES2015 because MediaWiki 1.34.0 doesn't support latest EcmaScript (ES2020).

I used Babel to do so (i.e, I "babelified" the code).