To handle users who like to occasionally use the custom ellipsis character from MS Word in titles, I would like to add replacement options for the character in the Punctuation settings for Pathauto using hook_pathauto_punctuation_chars_alter(). The problem is determining what value to put in the value setting in the hook. I found the T_ELLIPSIS constant in tokenizer.php, and tried using it like so:

function my_module_pathauto_punctuation_chars_alter(array &$punctuation) {
  $punctuation['ellipsis'] = array(
    'value' => T_ELLIPSIS,
    'name' => t('')

and the value shows as Ellipsis (389) for the field label in the settings. However, when the alias is generated with the ellipsis character in the node title, it doesn't get replaced.

Is there a better/easier way to handle this? Also, should I use something like the UTF-8 code instead of the constant?


My prefered solution to scrub out extraneous characters in Pathauto URLs is this option under Configuration » Search and metadata » URL aliases » Settings.

enter image description here

It will scrub out all the extraneous characters that can mess up browsers/crawlers. This is assuming you're on an English language website.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.