Multi-lingual blog – taxonomy – Tarski theme display II

An update to my recent post about tagging post languages with the language used. Another thing I wanted is the display of flags instead of the short code of the language. In this post I explain how I achieved that with one additional plugin and an extension of code (Tarski extension plugin) shown in the previously mentioned post.

language-tagging-2

Before continuing, one has to set up a new taxonomy as decribed in the previous post.

Adding taxonomy flags

I first tried to use the Ultimate CMS extended fields for adding images, but there seems to be no programmatical interface to get the values, so I decided to use the simpler approach and install the plugin Sideways8 Simple Taxonomy Images. After installing and activating the plugin you will find a new column in the table of Languages under Posts, called Taxonomy Image.

For the actual language flags I used the freely available icons from the Drupal project, available from the Drupal Language Icons web page.

Displaying a language flag in the post header

A small variation of the code posted before allows the flag to show up instead of the language short codes.

ID, 'language', array("fields" => "all"));
    $first = true;
    foreach ($term_list as $term) {
      if (!$first) {
        $metadata .= ', ';
        $first = false;
      }
      $imgsrc = s8_get_taxonomy_image($term, 'full');
      if ($imgsrc != false) {
        $metadata .= '' . $imgsrc . '';
      } else {
        $metadata .= '' . $term->slug . '';
      }
    }
    $metadata .= ' | ';
    return $metadata;
}

add_filter('th_post_metadata', 'add_language_to_metadata', 0);

?>

As before, putting this file as tarski-meta-post-language.php into the folder wp-content/plugins/tarski-meta-post-language/ on your blog side allows you to activate it in the plugin setting. But do this only if you are using the Tarski theme, I don’t know what will happen if another theme is used.

Leave a Reply

Your email address will not be published. Required fields are marked *