Add a token for publication status

Created on 8 August 2019, almost 5 years ago
Updated 5 July 2023, 12 months ago

Background

Drupal core's "node" module (node.tokens.inc) registers replacement tokens for most base node data (content id, revision id, type, title, created, changed, author, langcode). It does not include a replacement token for the node status (published/unpublished).

Problem/Motivation

There are a number of contexts where sites might want to render, via a token, the node status:
1. The LinkIt module (and soon, Drupal core via โœจ Drastically improve the linking experience in CKEditor 5 Needs work ) provides an autocomplete listing of linkable nodes whose display can be customized by tokens; in this context, it is useful to content editors to know whether the node they are linking is published or not.
2. The Rules module supports the ability to create logic decisions based on token values, and a common rule involves whether or not a node is published.
3. Content moderation notification systems (e.g., drupal.org/project/content_moderation_notifications) send information about changing node status/state to users, using tokens.

Proposed resolution

Add token for publication status: [node:published_status] (Published, Unpublished)

Architectural rationale for putting it in core, as opposed to a contrib module, is that the node entity is provided by core, node status (published/unpublished) is a paradigm originating in core, and the node module in core already has a number of similar tokens defined.

Alternatives considered/contraindications

Folks might want to change the label of the "publication_status" output. For example, if they wanted "Unpublished" to render as a more comprehensible "Not published." In that case, this would be better as site-specific customization.

โœจ Feature request
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
Node systemย  โ†’

Last updated less than a minute ago

No maintainer
Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium mpp

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.69.0 2024