This is a quick article about the
drupal_alter() function using pathauto as an example.
In pathauto.inc, there is a
drupal_alter('pathauto_alias', $alias, $context) call, so we can implement our own function to alter the alias generated by pathauto.
In our example module we need to create a new function, where the first part of the function name is the
module name, "example_module", the second part is the
string, "pathauto_alias", used in the drupal_alert call and the third part is the
hook name, "alter". Arguments are (for Drupal 6) $data and $context.
/**
* Implementing drupal_alter() hook to override pathauto alias
*/
function example_module_pathauto_alias_alter($data, $context){
// you can do stuff with the data. No return required as $data is passed in by reference.
}
That's it. It is not very complicated. :)
Comments
thanks, but there's a typo
Also, is your comment textarea deliberately hidden?
Thanks for sharing this and I
Post new comment