Drupal Export path alias to code

Most configuration can be exported with Features; path aliases seem to be an exception. So, to export a path alias, I use the following technique in mymodule.install:

<?php
 
function mymodule_install() {
  // set a path alias for the forums landing page
  $path = array(
    'source' => 'forum',
    'alias' => 'bulletin-boards',
  );
  path_save($path);
}
 
function mymodule_uninstall() {
  $criteria = path_load('forum');
  if ($criteria) {
    path_delete($criteria);
  }
}
?>

Tags

Article Type

General