This project is not covered by Drupal’s security advisory policy.

About

Active Link Formatter provides a custom Formatter for Link field types. Once it is enabled and configured, it adds the "is-active" class to the link in case the current URL matches with the one set on it.

By default, link field types don't use this feature and don't provide a way to enable it. Having it disabled makes sense in most of the cases, but there are some on which we might have it working.

This module doesn't do anything special out of adding the 'set_active_class' parameter to the link render array to be taken into account by the link_generator service. Therefore it relies on the implementation done by Drupal Core on this matter. This implementation is done at: \Drupal\Core\Utility\LinkGenerator::generate() method.

Why should I use this module

In most of the cases you don't want to apply the is-active class on field links, only in the site navigation which is usually implemented with menus. For menus, Drupal adds the 'is-active' class in case it is needed.

However, in some cases you might want to have links with special styles in case you are in the same page than the link is pointing to. With this module you are able to cover these cases too.

How to use it

  1. Enable the Active Link Formatter module as any other module in Drupal.
  2. Go to your content type > View Display and use the "Active Link" formatter on the field you like.
  3. On the formatter settings enable the option "Process the links to add the is-active class if needed".
  4. Save
Supporting organizations: 
Funding for development

Project information

Releases