Problem/Motivation

It is not possible to tell whether terms are unpublished when looking at the taxonomy overview page.

Proposed resolution

Add an indication on the VocabularyOverview page.

Remaining tasks

Work out how to show publication status on the taxonomy overview page.
Add test coverage.

User interface changes

The taxonomy overview page indicates whether each term is published.

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Issue fork drupal-3397143

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

As a workaround, here's what I added to a custom module:

/**
 * Implements hook_form_FORM_ID_alter() for taxonomy_overview_terms.
 */
function MYMODULE_form_taxonomy_overview_terms_alter(&$form, FormStateInterface &$form_state, $form_id) {
  foreach ($form['terms'] as $key => &$value) {
    if (is_array($value) && isset($value['term']) && is_array($value['term'])) {
      if (!empty($value['term']['tid']['#value'])) {
        $term = Term::load($value['term']['tid']['#value']);
        if (empty($term->status->value)) {
          $value['#attributes']['class'][] = 'term--unpublished';
        }
      }
    }
  }

  $form['terms']['#attached']['library'][] = 'MYMODULE/admin_tweaks';
}

MYMODULE.libraries.yml has this:

admin_tweaks:
  css:
    component:
      css/admin-tweaks.css: { }

css/admin-tweaks.css has this:

.term--unpublished {
  background-color: #fff4f4;
}

Hope this helps someone else.

vbouchet’s picture

Status: Active » Closed (outdated)
Related issues: +#3359159: Add Status to OverviewTerms.php form

I am closing as it seems a duplicate of #3359159 which was solved some time back.

vbouchet’s picture

Status: Closed (outdated) » Active

Actually reading at the exact title and the workaround, it seems more a visual indication which is requested here.

If we decide to so, it should be consistent with other places we list entities with "Status" column.

thebumik made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.