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).

Comments

jeremyheslop’s picture

StatusFileSize
new1.71 KB

Looks 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.

dave reid’s picture

Project: Pathauto » Date
Version: 6.x-1.1 » 6.x-2.x-dev

Date tokens are provided by date.module. The [mod-????] tokens will be fixed with #375887: Add a 'since' date token.

aaronpinero’s picture

Does 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?

lyricnz’s picture

The 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).

lyricnz’s picture

I'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

aaronpinero’s picture

@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?

lyricnz’s picture

StatusFileSize
new49.84 KB
lyricnz’s picture

That 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

dave reid’s picture

Status: Active » Fixed

Fix 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.

lyricnz’s picture

Thanks, Dave

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.