0

Use case: Custom module to alter CONTENTTYPE_node_forms to hide some of many entity reference options when adding/editing a node. Then via a custom validate I set $form_state['values']['path']['pathauto'] = 0 and want to set the $form_state['values']['path']['alias'] depending on the parent item of the chosen entity reference since unfortunately Pathauto doesn't provide tokens for that. Finally the alias should look like that: parent-entity/entity/$form_state['input']['title'].

I builded that pattern by hand now and I'm asking me after I couldn't find anything, if I also have to rebuild the whole str_replace/preg_replace pattern of Pathauto or if there's a way to reuse the same pattern Pathauto is using for replacing spaces, special characters etc.?

Or is there maybe any other intelligent alternative to set a path alias pattern like that?

marked as duplicate by leymannx, Mołot, Free Radical, Bala, mpdonadio Apr 1 '14 at 13:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Can't quite understand what you're asking, but on the off-chance you're referring to _pathauto_clean_string(), then yes, you can re-use that with your custom logic – Clive Mar 31 '14 at 11:53
  • Exactly what I was looking for! – leymannx Mar 31 '14 at 12:08

Browse other questions tagged or ask your own question.