Skip to main content

Aliases indeed disappear from nodes with non-default language after disabling language prefix in URLs. The solution to that is easy, but you have to do it in code, using Pathauto's hook_pathauto_alias_alter()hook_pathauto_alias_alter().

Basically all you need to do is:

function yourcustommodule_pathauto_alias_alter(&$alias, array &$context) {
  // Force all aliases to be saved as language neutral.
  $context['language'] = LANGUAGE_NONE;
}

This way you make sure that the language of the saved alias (not of node!) will always be 'und'und, meaning it will show for nodes of all languages.

NBNote: For existing aliases it is not enough to re-save the node -- you. You have to delete the alias first and then have it recreated. Often the easiest is to do it in bulk via Pathauto's configuration interface -- first. First delete all paths, then bulk-recreate them.

For more, see https://www.drupal.org/node/1234924

Aliases indeed disappear from nodes with non-default language after disabling language prefix in URLs. The solution to that is easy, but you have to do it in code, using Pathauto's hook_pathauto_alias_alter().

Basically all you need to do is:

function yourcustommodule_pathauto_alias_alter(&$alias, array &$context) {
  // Force all aliases to be saved as language neutral.
  $context['language'] = LANGUAGE_NONE;
}

This way you make sure that the language of the saved alias (not of node!) will always be 'und', meaning it will show for nodes of all languages.

NB For existing aliases it is not enough to re-save the node -- you have to delete the alias first and then have it recreated. Often the easiest is to do it in bulk via Pathauto's configuration interface -- first delete all paths, then bulk-recreate them.

For more, see https://www.drupal.org/node/1234924

Aliases indeed disappear from nodes with non-default language after disabling language prefix in URLs. The solution to that is easy, but you have to do it in code, using Pathauto's hook_pathauto_alias_alter().

Basically all you need to do is:

function yourcustommodule_pathauto_alias_alter(&$alias, array &$context) {
  // Force all aliases to be saved as language neutral.
  $context['language'] = LANGUAGE_NONE;
}

This way you make sure that the language of the saved alias (not of node!) will always be und, meaning it will show for nodes of all languages.

Note: For existing aliases it is not enough to re-save the node. You have to delete the alias first and then have it recreated. Often the easiest is to do it in bulk via Pathauto's configuration interface. First delete all paths, then bulk-recreate them.

For more, see https://www.drupal.org/node/1234924

Source Link
Vacilando
  • 724
  • 6
  • 17

Aliases indeed disappear from nodes with non-default language after disabling language prefix in URLs. The solution to that is easy, but you have to do it in code, using Pathauto's hook_pathauto_alias_alter().

Basically all you need to do is:

function yourcustommodule_pathauto_alias_alter(&$alias, array &$context) {
  // Force all aliases to be saved as language neutral.
  $context['language'] = LANGUAGE_NONE;
}

This way you make sure that the language of the saved alias (not of node!) will always be 'und', meaning it will show for nodes of all languages.

NB For existing aliases it is not enough to re-save the node -- you have to delete the alias first and then have it recreated. Often the easiest is to do it in bulk via Pathauto's configuration interface -- first delete all paths, then bulk-recreate them.

For more, see https://www.drupal.org/node/1234924