Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I can't seem to make hook_pathauto_alias_alter() get called in my custom module, in either 1.x or 2.x. I'm not certain, but I'm not clear if this hook is even in pathauto 1.x.

I am trying to hook into a Pathauto alias right before it's saved, so I can make some changes to the path (remove certain words). How do you do this? Is there another method besides a hook in the Pathauto module?

I have a module that let's the user enter in a list of words they want to filter from nodes; I would prefer not to enter it in two places.

share|improve this question

1 Answer

up vote 5 down vote accepted

The UI has this built in as it happens, if you visit http://mysite.com/admin/build/path/pathauto and look in the "General Settings" fieldset you'll find a textbox containing a list of strings to remove from aliases:

screenshot

hook_pathauto_alias_alter is definitely the right way to do it; it's available in both the 1.x and 2.x branches. Have you run any debug code to see if the hook is actually being called? And did you clear the caches? Hook implementations are cached (in Drupal 7 anyway; I can't remember if they are in Drupal 6 or not).

In case you're still wondering most modules that declare hooks come with a MODULENAME.api.php file which lists those hooks and how to use them. In the case of pathauto the file and hook function declarations are there, but sadly there's no documentation.

share|improve this answer
Thanks! I cleared cache a few times and wasn't seeing it called (I tossed in a die()). Can you point me where in the code of pathauto 1.x this hook is defined? – Justin Mar 9 '12 at 22:33
1  
Oh brain-dead friday! Somehow this hook is working after trying again. Maybe I spelled it wrong? Ugh ugh ugh sad face. Thanks! If you make this suggestion an answer I will accept. – Justin Mar 9 '12 at 22:35
@Justin Will do, glad you got it sorted :) – Clive Mar 9 '12 at 23:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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