You are here

function pathauto_create_index_alias in Pathauto 5

2 calls to pathauto_create_index_alias()
node_pathauto_bulkupdate_indexes in ./pathauto_node.inc
pathauto_create_alias in ./pathauto.module
Apply patterns to create an alias

File

./pathauto.module, line 441

Code

function pathauto_create_index_alias($alias, $module) {
  $count = 0;
  $components = explode('/', $alias);

  // Not interested in the trailing component
  array_pop($components);
  $alias = '';
  foreach ($components as $component) {
    if ($alias) {
      $alias .= '/' . $component;
    }
    else {
      $alias .= $component;
    }
    $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s'", $alias));
    if (!$alias_count) {
      $src = "pathauto/{$module}/{$alias}";
      _pathauto_set_alias($src, $alias);
      $count++;
    }
  }
  return $count;
}