Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module provides a way to display taxonomy term machine names, labels, and links as separate fields within a taxonomy reference field. This allows for exposing predictable key/value data, which is useful for APIs and front-end consumers.

INTRODUCTION

The Taxonomy Machine Name Field Formatter module provides a field formatter for taxonomy reference fields that outputs term properties in a list of separate fields per term.

Note from the author:

  • It’s another one of those "scratch my own itch" modules.
  • I created this module to get results quickly and because I was unsure about the current maintenance state of the parent Taxonomy Machine Name project.
  • The end goal is to contribute this formatter back and merge it into the parent module, if the maintainers are interested in adopting and maintaining this code.

Primary use cases:

  • Expose raw string-based values to front-end consumers or APIs as predictable key/value data.

REQUIREMENTS

INSTALLATION

Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.

CONFIGURATION

  • Add or edit an entity display that includes a taxonomy term reference field.
  • Choose the Machine name with Label output
  • Configure options:
    • Link label to the referenced entity
    • Link and label as seperated items
  • Save the display settings.

The option Link and label as seperated items is only available if you turned Link label to the referenced entity on.

Output

The variables per term passed to the template are a combination of the following fields

Array
(
    [machine_name] => Array
        (
            [#type] => inline_template
            [#template] => {{ value }}
            [#context] => Array
                (
                    [value] => some_term
                )
        )

    [link] => Array
        (
            [#type] => inline_template
            [#template] => {{ value }}
            [#context] => Array
                (
                    [value] => /taxonomy/term/2
                )
        )
    [label] => Array
        (
            [#type] => inline_template
            [#template] => {{ value }}
            [#context] => Array
                (
                    [value] => Some Term
                )
        )
    [label] => Array
        (
            [#type] => link
            [#title] => Some term
            [#url] => {\Drupal\Core\Url}
            [#options] => Array 
                (
                    [entity_type] => taxonomy_term
                    [entity] => {\Drupal\Core\Entity\Term}
                    [language] => {\Drupal\Core\Language\Language}
                )
        )        
)

Activity

Total releases
1
First release
Nov 2025
Latest release
8 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
1.0.x-dev Dev Nov 13, 2025