Drupal 8 Add another plateforme to Social Media Links Module

Profile picture for user a.berramou
Azz-eddine BERRAMOU 1 March, 2020

The Social Media Links module provides a configurable block that display links (icons) to your profiles on various popular networking sites.
It's very complete module and it support a lot of plateformes but sometimes you need to add other plateformes, in my case i needed to add my profile link of Drupal stackexchange plateforme, but it's not supported by default in the module.

To add another platform you need to create another Plugin inside src/Plugin/SocialMediaLinks/Platform, like the the following.

<?php

namespace Drupal\MODULENAME\Plugin\SocialMediaLinks\Platform;

use Drupal\social_media_links\PlatformBase;

/**
 * Provides 'Drupal Exchange' platform.
 *
 * @Platform(
 *   id = "stack-exchange",
 *   name = @Translation("Drupal Exchange"),
 *   urlPrefix = "https://drupal.stackexchange.com/users/",
 * )
 */
class DrupalExchange extends PlatformBase {}

Note: i gave my plugin stack-exchange as id, because the generated icon will have class based on plugin id like fa-PLUGIN_ID for Font Awesome,  so to get the right icon for my new plateforme i gave the plugin the the below id.

Now just clear cache, and go to your Social Media links block configuration page, you will find your new plateforme.

Enjoy!