- Issue created by @dgwolf
- π¨π¦Canada mandclu
It isn't clear from the issue description exactly what tokens you're attempting to use. It does sound as though maybe you're trying to use the ":format:xxx" token (which expects the machine name of a Smart Date format) with ":value-custom:xxx" which expects a PHP formatting string, but it is also entirely possible that I have misunderstood.
Here's an example of a token I have successfully used with a Smart Date field, albeit in Acquia Site Studio and not pathauto:
[node:field_when:value-custom:Y]
As for creating the format, I tried your example of 'ymd' for the date string, and the configuration page shows 230123 for me, which is correct for the Jan 23, 2023.
Thanks, mandclu, for the time and sorry for squeezing the format issue into the value-custom issue report. Your example β¦value-custom:Y expression nevertheless gets rejected by pathauto. Maybe a that is a limitation of pathauto. Will leave it at that for now.
I also repeated creating a custom format in the SD settings, this time no spurious y value appeared, 230125 is the intended output now.- π¨π¦Canada mandclu
Not sure if this is related, but I just discovered that some tokens (especially using the custom format) work when the devel module is enabled but don't when it is not. I'm still digging into that, but it might be worth a try to get your pathauto patterns saved.
- πΊπΈUnited States dalemoore
I'm having this issue, too. I created a Smart Date format called "Year Only" (year_only) as well as "Month Only" (month_only) and then in Pathauto tried to create this alias:
events/[node:field_when:0:value-format:year_only]/[node:field_when:0:value-format:month_only]/[node:title]
Also tried this:
events/[node:field_when:0:value-custom:Y]/[node:field_when:0:value-custom:m]/[node:title]
But the URL is only ever events/node-title, not events/2023/02/node-title
Pathauto doesn't error and saves the alias config, but they don't work. :\
- π¨π¦Canada mandclu
For a while now I've been using a pathauto pattern like
/talks/[node:field_when:end_value-custom:Y]/[node:title]
and it's been working fine for me.I thought maybe the problem was related to the multivalued field and selecting the first value, so I created a new content type with a multivalued field, and using a pattern like
/workshops/[node:field_time:0:end_value-custom:Y]/[node:title]
worked fine for me.What version of the Token module do you have installed?
- Status changed to Needs review
almost 2 years ago 7:06am 11 February 2023 - π¨π¦Canada mandclu
Here's a patch that should help with most of the specific warnings cited in #5. Attaching these as a patch for convenience, but I'm going to go ahead and commit these changes since the fallbacks they provide are common sense.
-
mandclu β
committed adff3cde on 3.7.x
Issue #3335564 by mandclu: No other token format available or accepted...
-
mandclu β
committed adff3cde on 3.7.x
- πΊπΈUnited States dalemoore
I didn't apply the patch but instead updated the module, and that seems to have got rid of the errors. Thanks!
Re: Token, this site is on Drupal 9.5.3 with Token 8.x-1.11. The field is an unlimited value field, with the recur functionality set to allow recurring dates. But even if I don't enable the recur part and just use unlimited (tried with creating a different field), it still doesn't work with the token I've included. It does work with:
events/[node:field_when]/[node:title]
But the URL format is then:
/events/sat-feb-11-2023-all-day/node-title
I just tried this based on your note above:
events/[node:field_when:0:end_value-custom:Y]/[node:title]
But still no luck, just becomes /events/node-title
- π¨π¦Canada mandclu
I'm not sure if the challenges reported here are related, but a fix related to the tokens in smart_date_recur was recently merged as part of π LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call Fixed . Could someone who is still having issues try to either use the dev release or add the patch from that issue?
- πΊπΈUnited States dalemoore
I just installed the lastest dev (was on stable) and it doesn't appear to have done anything.
I'm attaching some screenshots of my configuration. Maybe I have something configured wrong? When you get a chance if you can confirm if this looks right. Otherwise, maybe something else is conflicting with it. But I'm getting zero errors in the logs now so not sure. But maybe both I and the original poster don't have something configured right.
Pathauto configuration
Field configuration
Date formats
Year only
Month only
- πΊπΈUnited States dalemoore
Well I just tried it on a completely different (non-live) site, running Drupal 8.9.19, Smart Date/Recurring 3.4.2, and Token 8.x-1.9 and it worked, so it's possibly a problem with this site. Will tinker some more to figure it out...
- π¬π§United Kingdom Alina Basarabeanu
I am facing the same issue.
In the past using Smart date version 3.5 the token [webform_submission:node:field_event_date:format:custom_smart_date_only] was just fine.
Upgrading to Smart date version 3.7 the token is not valid.
This field field_event_date is a multi-value smart date, so I tried many different tokens to make it work without luck.
Failing tokens:
[webform_submission:node:field_event_date:0:format:custom_smart_date_only]
[webform_submission:node:field_event_date:0:value-custom:custom_smart_date_only]
[webform_submission:node:field_event_date:0:start-custom:custom_smart_date_only]
[webform_submission:node:field_event_date:0:value:format:custom_smart_date_only]Until this is fixed we can't update to the latest version of the module.
- π¨π¦Canada mandclu
Thanks for everyone who has helped to provide additional detail on how to reproduce this. After some troubleshooting, I believe the problem is actual in the token processing that was added specifically in smart_date_recur. Here's a patch that got the token working again for me. If folks who have been having this issue can validate that this resolves their problems too, I will merge this in and roll new releases.
- πΊπΈUnited States dalemoore
Hi Martin,
I ran composer update and updated this site so all modules/core is up-to-date. I'm now on Drupal 9.5.4 running Token 8.x-1.11, Smart Date 3.7.x-dev
Applied the patch and it doesn't seem to have affected anything. Tried these tokens/aliases and none work:
events/[node:field_when:0:value]/[node:title]
events/[node:field_when:1:value]/[node:title]
events/[node:field_when:0:end_value]/[node:title]
events/[node:field_when:0:duration]/[node:title]
events/[node:field_when:0:format:year_only]/[node:title]
events/[node:field_when:0:value-custom:Y]/[node:title]Could you provide what URL format you're using on recurring events that works for you? (I am, of course, going back and re-saving the node to check if the alias updates each time I change it. :))
- π¨π¦Canada mandclu
I set up a pattern like this, which tested two different token structures at once:
/events/[node:field_when:0:value-format:year_only]/[node:field_when:0:value-custom:m]/[node:title]
Without the patch, my test event ends up with a path like /events/test-event and after applying the patch and re-saving the node, it had a path like /events/2023/02/test-event
- π¬π§United Kingdom darren.fisher
I was having this issue and the patch in #14 https://www.drupal.org/project/smart_date/issues/3335564#comment-14948369 π No other token format available or accepted besides the default one Fixed fixes it for me. Thank you!!
- πΊπΈUnited States dalemoore
Darren is right, I messed up applying the patch. It does work now! Awesome, thanks Martin. :) (BTW, love your MotW portion on Talking Drupal!)
-
mandclu β
committed f9e69da6 on 3.7.x
Issue #3335564 by mandclu: No other token format available or accepted...
-
mandclu β
committed f9e69da6 on 3.7.x
-
mandclu β
committed f9e69da6 on 4.0.x
Issue #3335564 by mandclu: No other token format available or accepted...
-
mandclu β
committed f9e69da6 on 4.0.x
- Status changed to Fixed
almost 2 years ago 6:08pm 2 March 2023 - π¨π¦Canada mandclu
Thanks for the feedback! Merged this in, and will try to roll a new release shortly.
@dalemoore Glad you're enjoying MotW :-) Suggestions are always welcome
Automatically closed - issue fixed for 2 weeks with no activity.