0

Is it possible for Pathauto to have one pattern for a content type, and a different pattern for the same content type based on the value of a field in that content type? I have a checkbox field and if its checked I want to use a different pathauto setting. Right now the only condition Pathauto has is based on content type. Is there a hook that can do this.

2

Yes. There exists hook_pathauto_pattern_alter() for this purpose. Per the docs:

Alter the pattern to be used before an alias is generated by Pathauto.

This hook will only be called if a default pattern is configured (on admin/config/search/path/patterns).

A hook invocation takes arguments in which you can inspect the type and alter &$pattern accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.