I have a brand field wich have a & character

I want to keep this character in my field, but i would like to change it by a "and" in the url alias.

Any idea how to make it ?

Thanks for your answers

Comments

Jibus’s picture

Project: Pathauto » Transliteration
Version: 7.x-1.1 » 7.x-3.1

Move this to the transliteration queue

amateescu’s picture

Project: Transliteration » Pathauto
Version: 7.x-3.1 » 7.x-1.x-dev

I think this is a question for Pathauto, not Transliteration.

Jibus’s picture

Oops, sorry then =)

Finally, i have just override manually the alias into node form.

But the question remains if you have a lot of nodes where you want to convert the & into a "and"

Maybe it's possible with rules

ben.kyriakou’s picture

Issue summary: View changes
Status: Active » Fixed

It doesn't look like there's a straightforward way to do this natively in Pathauto without changing the available transformations for punctuation. The simplest way to do this is probably with hook_pathauto_alias_alter(). Ensure that Ampersands are set to "No action (do not replace)" at /admin/config/search/path/settings, then add a hook_pathauto_alias_alter() in a custom module like this:


function mymodule_pathauto_alias_alter(&$alias, array &$context) {
  $alias = str_replace('&', 'and', $alias);
}

This will then replace any ampersands in your URL with the word 'and'.

I'm going to mark this as Fixed since this should solve your issue, but if you have further questions please set it back to Active. If you'd like this to be a fully-fledged feature of the module, then consider filing this as a Feature request.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.