Arsenii
Arsenii

Reputation: 774

How to add custom internal link to footer in MediaWiki?

I am trying to add internal link to the footer of our wiki on MediaWiki, using the guidelines in their documentation.

The goal is to add the code to the LocalSettings.php. I am adding the code below to my LocalSettings.php:

$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
    if ( $key === 'places' ) {
        $footerlinks['Page name to display'] = $skin->footerLink( 'Some desctription', 'Page' );
    };
};

I have changed different skins, but this does not work. I see only default pages (which I can hide by changing their contents to "-"). Also, I have tried to echo var_dump($skin) and this gives a white page (error, obviously). Also, I was trying echo wfVarDump($skin), but the same result - white page. It looks like somewhere the skin is not set properly. I mean, not by me, since I have added all the skins as described in their manuals and also the skins work completely properly, other than footer links.

The other thing is that all my Wiki is in Cyrillic and all the pages are named in Cyrillic. Can this be a problem?

However, I have tried (to test) a code as bellow too:

$wgHooks['SkinAddFooterLinks'][] = function ( Skin $skin, string $key, array &$footerlinks ) {
        if ( $key === 'places' ) {
            $footerlinks['Page name to display'] = $skin->footerLink( 'Some desctription', 'MediaWiki:Aboutsite' );
        };
    };

As you can see - there is a page, that is permanently present in the system (however, its content is a dash "-" now). But no luck to have this displaying via SkinAddFooterLinks. I am using MediaWiki 1.39.3.

Any help is appreciated!

Upvotes: 0

Views: 246

Answers (1)

Robis Koopmans
Robis Koopmans

Reputation: 408

Skin::footerLink needs two message keys. If this is set to nonexisting message key or the message is disabled, the link will not be generated, empty string will be returned instead

Skin::footerLink

Given a pair of message keys for link and text label, return an HTML link for use in the footer.

<?php
public function footerLink($desc, $page) { }
@param string $desc
The i18n message key for the link text. The content of this message will be the visible text label. If this is set to nonexisting message key or the message is disabled, the link will not be generated, empty string will be returned in the stead.

@param string $page
The i18n message key for the page to link to. The content of this message will be the destination page for the footer link. Given a message key 'Privacypage' with content 'Project:Privacy policy', the link will lead to the wiki page with the title of the content.

@return string — HTML anchor

You can create the message keys by creating pages in the MediaWiki namespace.

Example:

MediaWiki:Page-link-text

My link

MediaWiki:Page-link

Main_Page

The content of the first message page is just a word, the content of the second message page is the page you want to link to.

Example:

$footerlinks['my-link'] = $skin->footerLink( 'Page-link-text', 'Page-link' );

Upvotes: 1

Related Questions