I've been able to use tokens like [field_mydate-to-value] as the node's title using the auto_nodetitle module.
Trying to use the same token in pathauto results in
You are using the token [field_mydate-to-value] which is not valid within the scope of tokens where you are using it.
If I replace the token with [field_mydate-value], it works: the "from-" date is used; why can't I use the "to-" date in pathauto as I can in auto_nodetitle? is this a pathauto problem? or a date problem?
I'm using the latest 6.x-2.x-dev release of date (2009-02-17).
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | URL aliases | My Private Chef.jpg | 49.84 KB | lyricnz |
| #1 | date_token-20090520.patch | 1.71 KB | jeremyheslop |
Comments
Comment #1
jeremyheslop commentedLooks like it is an issue in pathauto that could be corrected in the _pathauto_check_pattern function in the pathauto.admin.inc file. There needs to be a check for the -???? after a pattern. Both the token module:
./token/token_node.inc: $tokens['node']['mod-????'] = t('All tokens for node creation dates can also be used with with the "mod-" prefix; doing so will use the modification date rather than the creation date.');
and the date module use this syntax for listing their tokens:
./date/date/date_token.inc: $tokens['date']['to-????'] = t("If the field has a to-date defined, the same tokens exist in the form: [to-????], where ???? is the normal token.");
There might be other modules that use this syntax.
For now I just hacked the date module. You can apply the attached patch to the modules/date/date/date_token.inc file to add each pattern for the to-???? then you can use pathauto without issues, but I'm sure there is a better way to handle this in the pathauto module.
Comment #2
dave reidDate tokens are provided by date.module. The [mod-????] tokens will be fixed with #375887: Add a 'since' date token.
Comment #3
aaronpinero commentedDoes the patch in #1 work? And if so can this get committed to the Date module so we don't have to be hacking the code?
Comment #4
lyricnz commentedThe reason date module used ['to-????'] is shorthand for the many tokens that are already listed for the primary/from date. If we included them all explicitly, that would be a LOT more tokens for each date field.
The validation of tokens by pathauto is now actually performed by token_element_validate_token_context() in token module.
So, two solutions: extend wildcard support in token validation (there is some already), or explicitly add all the tokens to date (and any other module that does the same thing).
Comment #5
lyricnz commentedI've submitted a feature-request to token module to extend the wildcard support, in part to address this issue. See #1147452: Add support for non-numeric wildcards during validation
Comment #6
aaronpinero commented@lyricns, thank you for clarification on this issue and for submitting the request. So from your comments, should I understand that the patch above does actually work?
Comment #7
lyricnz commented@aaronpinero: yes, the patch in #1147452: Add support for non-numeric wildcards during validation works.
Comment #8
lyricnz commentedThat other issue now looks like it's tending towards supporting a form of wildcards that aren't useful for this problem. If you don't mind patching Token in the meantime, use the patch in
http://drupal.org/node/1147452#comment-4433226
Comment #9
dave reidFix in #1147452: Add support for non-numeric wildcards during validation has been committed to Token 6.x-1.x-dev. I was able to use [field_date-to-value] and it passed validation.
Comment #10
lyricnz commentedThanks, Dave