URLSegment character mapping

Member since: 2004
 

Hi,

we need to have different mappings for the urlsegment depending on which language is edited. Is there a way to configure this somehow? And also, is there a way to add like "oe" as replacement for "ö"? Today UrlSegment.URLCharacterMap is a char[,] which means that's a problem.

Thanks,
Erik

Ps. I have solved this issue with some nasty code, just want to know if there is a best practice I'm missing out on.. :)

#121912 May 20, 2015 12:37
  • Member since: 2011
     

    Hi,

    I believe you can set the UrlSegment.URLCharacterMap to override the replacement characters, no? It's just a Hastable with set access.

    Regards.

    /Q

    #121914 May 20, 2015 13:22
  • Member since: 2004
     

    Hi Quan,

    I tried that, but if i add/change to a string instead of a char as replacement, I get a cast exception later on.

    /Erik

    #121915 May 20, 2015 13:30
  • Member since: 2004
     

    I guess it's in internal static string ReplaceIllegalChars(string inputString) it happens.

    #121916 May 20, 2015 13:32
  •  

    Hi,

    The URLCharacterMap.URLCharacterMap is a public static property. You could try to setup it somewhere in your bootstraper.

    #121917 May 20, 2015 13:37
  • Member since: 2011
     

    Hmm, so instead of mapping character-character you want character-string instead.

    I have tried yet but I think you can overwrite the default ContentProvider.GetUniqueUrlSegment and do the stuff here. It calls to UrlSegment.GetUrlFriendlySegment, which unfortunately un-overridable. 

    Just not sure if this approach is even nastier than yours :).

    Regards.

    /Q

    #121921 May 20, 2015 13:43
  • Member since: 2011
     

    Hmm, so instead of mapping character-character you want character-string.

    I have tried yet but I think you can overwrite the default ContentProvider.GetUniqueUrlSegment and do the stuff here. It calls to UrlSegment.GetUrlFriendlySegment, which unfortunately un-overridable. 

    Just not sure if this approach is even nastier than yours :).

    Regards.

    /Q

    #121922 May 20, 2015 13:43
  • Member since: 2004
     

    Hehe, I think I'll stick to the current solution. It ignores ä,ö,ü and ß in the character mapping, then in UrlSegment.CreatedUrlSegment I replace them myself with ae, oe, ue and ss.

    /Erik

    #121923 May 20, 2015 13:50