0

i´m kind of a noob in php things and i got the following problem:

i got a plugin which helps me making a website with 2 languages. So i tell the plugin which languages i want to have in my contao-backend and then i can use them in the frontend. I can then chose wether i want to be able to switch the language by clicking on a flag or by clicking the language in a select box. But there is no option to just have the languages next to each other without a flag. Just a text like "German Spanish". its always a select box or flags.

I then opened the template for the select box and it tells me this:

<?php
/**
 Menu for switching between languages of a page.
 */

?><form name="<?php echo $this->type;?>" method="post"  style="display:inline"
><select name="language" onchange="this.form.submit();">

<?php foreach ($this->items as $item): ?>
<option value="<?php echo $item['language'];?>" <?php 
    if ($item['isActive']) {
        echo ' class="active" selected="selected"';
    } ?>><?php 
    echo $this->languages[$item['language']];
?></option>
<?php endforeach; ?></select><input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}" /></form>

(This is the one where i can switch by a select box)

and:

<form name="<?php echo $this->type;?>" method="post"  style="display:inline"
><?php foreach ($this->items as $item): ?><input 
    class="language" type="radio" name="language" 
    id="language_<?php echo $item['language'];?>" 
    onchange="this.form.submit();"
    value="<?php echo $item['language'];?>" <?php 
if ($item['isActive']) {echo ' class="active" checked="checked"';} ?>  />
<label for="language_<?php echo $item['language'];?>" <?php 
    if ($item['isActive']) {echo ' class="active"';} ?>><img src="<?php 
echo 'system/modules/i18nl10n/html/flag_icons/png/'.$item['language'].'.png';?>"
title="<?php echo $this->languages[$item['language']];?>"
alt="<?php echo $this->languages[$item['language']];?>"
/></label><?php endforeach; ?><input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}"></form>

(this is the one which lets me change the language by clocking on the flag)

....

my question now is if someone knows how i can edit this code in a way that it simply shows me the languages i can chose in a text like "german spanish".

Sorry for my english :P

greetings

1 Answer 1

0

You can just remove the <img> tag and replace it with the language name: (I have also improved the code formatting for better readability)

<form name="<?php echo $this->type;?>" method="post"  style="display:inline">
    <?php foreach ($this->items as $item): ?>
        <input class="language" type="radio" name="language"
             id="language_<?php echo $item['language'];?>" 
             onchange="this.form.submit();"
             value="<?php echo $item['language'];?>"
             <?php 
                 if ($item['isActive']) {
                     echo ' class="active" checked="checked"';
                 }
             ?>
        />
        <label for="language_<?php echo $item['language'];?>"
            <?php if ($item['isActive']) { echo ' class="active"'; } ?>
        >
            <?php echo $this->languages[$item['language']];?>
        </label>
    <?php endforeach; ?>
    <input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
</form>
0