Simple Languagemenu with iso-code

Tips, Tricks & Workarounds [en] / [de]

Moderator: KB Moderators

Locked
olape
Posts: 3009
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Simple Languagemenu with iso-code

Post by olape » Thu Oct 17, 2024 1:07 pm

A very simple language menu. Output as iso code instead of flags.
A slimmed-down version of the original language menu.

This code insert to /cmsimple/userfuncs.php

Code: Select all

<?php

function simple_languagemenu() {

    global $pth, $cf, $sl;

    $r = XH_secondLanguages();
    array_unshift($r, $cf['language']['default']);
    $i = array_search($sl, $r);
    unset($r[$i]);

    $t = '<div class="simple_languagemenu">' . "\n";
    $t .= '<span>' . $sl . '</span>';
    foreach ($r as $lang) {
        $url = $pth['folder']['base']
             . ($lang == $cf['language']['default'] ? '' : $lang . '/');
        $el = $lang;
        $t .= '<a href="' . $url . '">' . $el . '</a>';
    }
    $t .= '</div>' . "\n";

    return $t;
}

Up to XH 1.7.6 you have to replace the call of the language menu in the template.

Code: Select all

<?=languagemenu();?>
to

Code: Select all

<?=simple_languagemenu();?>
As of XH 1.8, you only need to enter 'simple' under 'Languagemenu' in the XH configuration.
Changes to the template will no longer be necessary.

This menu can be visually customized with the '.simple_languagemenu' class.
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

Locked