Add a class for publication status

Created on 12 June 2017, almost 8 years ago
Updated 2 June 2025, 6 days ago

If I want to build a sub-theme of Seven to indicate an icon for publication status, can you alter function seven_form_node_form_alter() in seven.theme ?

Like this for example :

 $is_new = !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet');
  //Here
  $pub_status = $node->isPublished() ? 'status-published' : 'status-unpublished';

  $form['meta'] = [
    '#attributes' => ['class' => ['entity-meta__header']],
    '#type' => 'container',
    '#group' => 'advanced',
    '#weight' => -100,
    'published' => [
      '#type' => 'html_tag',
      '#tag' => 'h3',
      '#value' => $node->isPublished() ? t('Published') : t('Not published'),
      '#access' => !$node->isNew(),
      '#attributes' => [
        'class' => ['entity-meta__title', $pub_status],
      ],
    ],

Thx

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France mgerbault

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024