phpdrupaldrupal-6drupal-modulespathauto

How to change Automated alias settings on module install?


Situation:

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