如何更改模块安装时的自动别名设置


How to change Automated alias settings on module install?

情况:

  • Drupal 6节点模块定义自定义内容类型
  • 需要为内容类型设置自动别名,例如content_type/[title-raw]

问题:如何在hook_install中以编程方式将新内容类型的"自动别名"设置为上述模式?

解决方案微不足道,Drupal的自动别名模式存储在变量中:

function hook_install()
{
    variable_set('pathauto_node_[content_type]_pattern', 'content_type_path/[title-raw]');
}

其中CCD_ 3是指内容类型的机器可读名称,而CCD_。

该解决方案是从http://drupal.org/node/1246334#comment-5038566