Closed (outdated)
Project:
Drupal core
Version:
11.x-dev
Component:
token system
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
19 Apr 2013 at 19:46 UTC
Updated:
14 Jul 2025 at 14:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
xanoThis patch takes a slightly different approach. It hardly alters the token API and keeps hook_tokens() implementations responsible for the default tokens, but it moves this responsibility from scattered implementations to the implementation of the module that actually defines the token type. The patch currently only converts the node:author token to this new approach as an example, but converting the other tokens should not be hard.
Comment #4
xano#1: drupal_1975126_00.patch queued for re-testing.
Tests pass locally.
Comment #5
xanoThis patch converts some more (if not all) default tokens.
Comment #6
dave reidVery interesting. I feel like it's a bit of magic with an empty string as the $name, which makes sense, but it's hard to explain that to people implementing the token API that it means that it's the default token, and should not be used more than once. And that it should not be implemented for global tokens.
I wish that we could make this work by using information in token_info() by setting a 'default' => TRUE flag on a specific token for a specific type, but this may be a good start.
[site:] is a global token, and should not have a default token name.
Comment #7
xanoI share your point of view. It makes sense, because there is no child token, yet using an empty identifier to identify something is conceptually weird.
Why not?
What if there are multiple default tokens? If we want this, a better solution may be to specify the default token on the token type, than on the tokens themselves.
I am starting to think we may get rid of these defaults altogether and just say [site] and [node] and [user] are invalid tokens and will not be replaced. The main problem I wanted to solve here was that hook_tokens() implementations don't all have their own (possibly different) implementations of default tokens for the exact same token type, which leads to duplicate code and inconsistencies.
Comment #23
smustgrave commentedThank you for sharing your idea for improving Drupal.
We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #24
smustgrave commentedSince there's been no follow up in 3+ months going to close this one out, but if still a desired feature please re-open.
Thanks!