01.05.2006

I just recognized by incident that the great Ultimate Tag Warrior Plugin by Christine Davis doesn’t take German Umlauts into account correctly under certain circumstances, e.g. if you utilize the “related posts” feature like Binary Blue does (if configured this way). So I dug into the code of the core files of my currently installed 3.1 release of that plugin and found the appropriate function to modify. The mod you need to apply is pretty simple - I just added a few lines of code to make use of a hopefully installed and activated o42-Clean-Umlauts plugin (or its 4null4.de pendant):

function FormatPost($post, $format) {
  $URL = get_permalink($post->ID);

  // CleanUmlauts-Integration
  if (function_exists('o42_cu_content'))
  {
    $post->post_title   = o42_cu_content($post->post_title);
    $post->post_excerpt = o42_cu_content($post->post_excerpt);
    $post->post_content = o42_cu_content($post->post_content);
  }

  $format = str_replace('%title%', $post->post_title, $format);
  $format = str_replace('%postlink%', '<a href="'.$URL.'">'.$post->post_title.'</a>', $format);
  $format = str_replace('%excerpt%', $post->post_excerpt, $format);
  $format = str_replace('%postdate%',mysql2date(get_settings("date_format"), $post->post_date),$format);
  $format = str_replace('%content%', $post->post_content, $format);

  return $format;
}

To add appropriate support for German Umlauts in their correct character encoding, just replace the original FormatPost()-function in the core file of UTW with the code displayed above and reupload that file to your webserver, overwriting the original file in your UTW plugin directory - that’s it, full and correct German Umlaut support for the Related Posts lists.

Additionally, you can add full support for tags containing German Umlauts as well. Just do the following:


// original: $tag_name = strtolower($tag->tag);
$tag_name = utf8_decode(strtolower(htmlentities(utf8_decode($tag->tag))));
// original: $tag_name_url = urlencode(stripslashes($tag_name));
$tag_name_url = urlencode(stripslashes(strtolower($tag->tag)));

Look for the codelines 1092/1093 in the core file - it’s the two lines of code in the sample above I’ve commented out. Replace them with the code displayed above, reupload yadda yadda, and everything will be fine - both display of the tags as well as the distinct tag archives as well as the tag cloud will work perfectly then with german Umlauts as well.

Verwandte Artikel:



Hinweis: Wegen des hohen Aufkommens an Kommentarspam und als Kommentar getarnten Werbelinks werden alle Kommentare auf diesem Blog zuerst in die Moderation geschickt. Ich schalte neue Kommentare von echten Besuchern so schnell wie möglich frei. Beleidigende oder gegen geltendes Recht verstoßende Kommentare werden gelöscht.

Bisher 7 Kommentare zum Artikel

  1. Andreas meint

    you said: Additionally, you can add full support for tags containing German Umlauts as well. Just do the following: ….

    I tried it this way, but from my point of view it’s only half of the solution. If you save a post with umlaute tags more than once then tgas get changed every time you save the post (ü is replaced by &uuml; then in &amp;amp;uuml; and so on).

    I additionally changed line 572 in ultimate-tag-warrior-actions.php:
    from:

    $widget .= stripslashes(str_replace(’&’, ‘&’, $utw->FormatTags($utw->GetTagsForPost($postid, $limit), array(”first”=>’%tag%’, ‘default’=>’, %tag%’))));

    to:
    $widget .= stripslashes($utw->FormatTags($utw->GetTagsForPost($postid, $limit), array(”first”=>’%tag%’, ‘default’=>’, %tag%’)));

    with this change tags within posts don’t change anymore after each save operation.
    That’s ok for me.

  2. Thomas meint

    Sorry, it’s me again. I found out, that UTW is not producing lowercase tags. Only tags starting with a umlaut will be transformed to lowercase. But I think I have to accept this.

  3. Thomas meint

    Okay, thank you for the quick answer.

  4. CountZero meint

    As far as I know UTW always creates lowercase tags, so the behaviour seems normal to me. if you peek into the database table containing the tags you will see what I mean.
    Since Technorati and sorts are not case-sensitive, this should not be a problem except the visual style on the blog.

  5. Thomas meint

    Aloha.

    When I am writing a new post and use the Ö as part of a tag like in “Österreich”, the UTW always converts it to & ouml ; instead of & Ouml ; so that the tag looks like “österreich” instead of “Österreich”.

    Clear what I mean? How can I change this?

    Sorry about my poor english.

  6. CountZero meint

    probably yes…. have fun ;)

  7. Pål meint

    OK - so this’ll can be tweake to work on danish characters æ,ø,å also?