How to change Automated alias settings on module install?
-
26-05-2021 - |
Question
Situation:
- Drupal 6 node module defining custom content type
- Necessity to have an automated alias for the content type, e.g.
content_type/[title-raw]
Question: How can I programmatically set the Automated alias setting of the new content type to the above pattern in the hook_install
?
Solution
Solution is trivial, automated alias patterns of Drupal are stored in variables:
function hook_install()
{
variable_set('pathauto_node_[content_type]_pattern', 'content_type_path/[title-raw]');
}
where content_type
refers to the machine-readable name of the content type and content_type_path
is the desired prefix of the alias of the content type.
The solution was fetched from the post at http://drupal.org/node/1246334#comment-5038566
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow