Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Date, String, and Number types:
should have better token replacement support.
- Arguments with Date type should have the following replacement options: (my argument is called "date_sent")
[date_sent:date] The unmodified date value [date_sent:date-yyyy] The year (four digit) [date_sent:date-yy] The year (two digit) [date_sent:date-month] The month (full word) [date_sent:date-mon] The month (abbreviated) [date_sent:date-mm] The month (two digit, zero padded) [date_sent:date-m] The month (one or two digit) [date_sent:date-ww] The week (two digit) [date_sent:date-date] The date (day of month) [date_sent:date-day] The day (full word) [date_sent:date-ddd] The day of week (abbreviation) [date_sent:date-dd] The day (two digit, zero-padded) [date_sent:date-d] The day (one or two digit)
- Arguments with Number type should have the following replacement options: (my argument is called "amount")
[amount:number] The numeric value
- Arguments with String type should have the following replacement options: (my argument is called "name")
[name:string] The string value
I'm asking here first, but I suspect this a problem with the token module, not rules.
Comments
Comment #1
mitchell CreditAttribution: mitchell commentedIn 7.x, there is a whole new token structure. Please check how this issue may apply to 7.x and report back. New changes are going into that branch anyway.
Changing to support request for now until verifying changes are necessary.
Comment #2
klausiClosed since no further information has been provided. Reopen if still an issue.
Comment #3
bomarmonk CreditAttribution: bomarmonk commentedI'm reopening this, since I can't get my single date field (for a year) to show up formatted as a year (rules renders the date-entity and date_field token as an entire date string with a month, day and time, even though the field only collects the year).
Any way to have rules use the date field's proper format and content?
Comment #4
David Stosik CreditAttribution: David Stosik commentedHi bomarmonk,
Can you please have a look to this patch? #1898828: Add actions to format dates and durations
By adding an action "convert data", if you try to convert a date to a string, then you will get formatting options, and then will be able to use the provided variable in following actions.
David
Comment #5
TR CreditAttribution: TR commentedAll the date tokens are available if you use the contributed Token module, which enhances core Drupal's support for token:
Note there will be a separate token for each date format that you have configured at
/admin/config/regional/date-time
. Short/medium/long are built-in to Drupal. You have the choice of either defining a new format and using the token for that format, or using the "Custom" token and explicitly.So I don't see a need to add additional tokens just for use within Rules - all the Token module tokens are available for any date you have in Rules.