Ticket #2278 (closed enhancement: duplicate)

Opened 11 months ago

Last modified 4 months ago

better converting of umlauts into url

Reported by: benni Owned by: aoneil
Priority: medium Milestone: 2.2.3*
Component: CMS - General Version: 2.2.2-rc1
Severity: medium effort / impact Keywords:
Cc: sminnee Hours:

Description

hey

when I add a new page like e.g. "Der Mönch" the url should be automaticly converted into "/der-moench" and not into "der-m-nch".

greetings, benni

Change History

Changed 11 months ago by ischommer

  • cc sminnee added

i've used a customized drupal-snippet for a silverstripe client, which makes nicer URLs, e.g. "Wünsche Dir Spaß beim Soirée" -> "wuensche-dir-spass-beim-soiree". see http://drupal.org/node/63924

$str = preg_replace('~[^\\pL0-9_]+~u', '-', $str); // substitutes anything but letters, numbers and '_' with separator 
$str = trim($str, "-");
$str = iconv("utf-8", "us-ascii//TRANSLIT", $str); // TRANSLIT does the whole job
$str = strtolower($str);
$str = preg_replace('~[^-a-z0-9_]+~', '', $str); // keep only letters, numbers, '_' and separator

it relies on the iconv php extension and the "transliteration table", which seems to be standard in PHP since PHP 4.0.x: http://uk.php.net/manual/en/function.iconv.php

the trickiest part here is making sure that "legacy urls" are still accessible. i'd suggest: 1. only generating URLs with the new code when no previous URLs are saved 2. providing a manual trigger to convert all urls to the new format, and add a "LegacyURL" field to the database. if this field is present, RootURLController will check against both fields when resolving a URL.

Changed 11 months ago by sminnee

I don't think that this change should affect our handling of old URLs. By default, this code will only affect the URL generation on new or edited pages.

A functions for doing a global update of all URLs to fit a new rule is a completely separate system.

One of the things that we were working on is making use of the SiteTree?_versions table to search for legacy URLs before redirecting to a 404.

Changed 10 months ago by sminnee

  • milestone set to 2.2.3 feature-lock

Changed 4 months ago by ischommer

  • status changed from new to closed
  • resolution set to duplicate

Duplicate to #2452 - we'll continue work and discussion there.

Note: See TracTickets for help on using tickets.