Theming and hooks

Last updated on
18 March 2025

Twig template

This module provides a social-media-platforms-links.html.twig with the following variables.

 * Available variables:
 * - attributes: HTML attributes for the item.
 * - display_options: An array of the display options
 *   - icon_source: The icon source ( none, image or font ).
 *   - show_label: Whether to show the label or not.
 *   - target_blank: Whether to add target_blank to the links.
 * - platforms: A nested list of link items. Each link item contains:
 *   - attributes: HTML attributes for the menu item.
 *   - image: The social media link image path.
 *   - font_classes: The icon font classes.
 *   - label: The link title.
 *   - url: The link URL, instance of \Drupal\Core\Url

Replace default image icons

The module implements a theme element 'social_media_platforms_links', which allows to alter the social media platform icons using a preprocess hook.

function THEME_preprocess_social_media_platforms_links(&$variables) {

  $variables['platforms']['facebook']['image'] = 'new image url';
  $variables['platforms']['youtube']['image'] = 'new image url';

}

CSS Library

The module comes with a minimal css library for styling the block 'social_media_platforms/social_media_platforms.theme'.

This library can be overriden or removed completely to use your custom css styles. For more information on how to do this, you can check here.

Here is an example of how it might look:

libraries-override:

  social_media_platforms/social_media_platforms.theme:
    css:
      theme:
        css/social_media_platforms.theme.css: my_css/replacement.css

Help improve this page

Page status: No known problems

You can: