Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Different Logo for Different Language

More
7 years 6 months ago - 7 years 6 months ago #163957 by benjaminschlegel
I am trying to expend the theme fruity. My goal is to display a different logo depending on the chosen language. I am updating the custom nav_bar.twig. I tried the following code, where I also tried {{ SURVEYLANG }}, { SURVEYLANG }, in small letters, with surveylanguage Capital and small letters and LANG in call variations.
Code:
        {# Logo option #}
        {% if( aSurveyInfo.options.brandlogo == "on") %}
            <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
        {% if( SURVEYLANG  == "fr") %}
          {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
        {% else %}
          {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
        {% endif %}
            </div>
        {% else %}
            <div class="{{ aSurveyInfo.class.navbarbrand }}"  {{ aSurveyInfo.attr.navbarbrand }} >
                {{ aSurveyInfo.name }}
            </div>
        {% endif %}

Does anyone know how I can do this?

Edit: I'm using Limesurvery 3.0.0.
Last edit: 7 years 6 months ago by benjaminschlegel.
The topic has been locked.
More
7 years 6 months ago #163966 by tpartner
Try this for your IF statement:

Code:
{% if( aSurveyInfo.surveyls_language  == "fr") %}
    {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% else %}
    {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% endif %}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: benjaminschlegel
The topic has been locked.
More
7 years 6 months ago - 7 years 6 months ago #163968 by benjaminschlegel
Thanks a lot, that worked!
Last edit: 7 years 6 months ago by benjaminschlegel.
The topic has been locked.
More
7 years 6 months ago #163978 by tpartner
For reference...in most template Twig files, you can see all available variables in the aSurveyInfo array by setting debug to 1 and placing this somewhere in the Twig file:

Code:
{{ dump(aSurveyInfo) }}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 10 months ago #190192 by tschaipi
And why doesn't the 3 language option work? I can't find the typo ...
Code:
{% if( aSurveyInfo.surveyls_language  == "fr") %}
    {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% else if( aSurveyInfo.surveyls_language  == "it") %}
    {{ image( "./files/logo_it_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% else %}
    {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% endif %}
Code:
[code]
[/code]
The topic has been locked.
More
5 years 10 months ago #190193 by DenisChenu
I don't think you have else if in twig :
twig.symfony.com/doc/2.x/tags/if.html

Then :
Code:
{% if( aSurveyInfo.surveyls_language  == "fr") %}
    {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% if( aSurveyInfo.surveyls_language  == "it") %}
    {{ image( "./files/logo_it_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% if( aSurveyInfo.surveyls_language  == "de") %}
    {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% endif %}

or
Code:
{% if( aSurveyInfo.surveyls_language  == "fr") %}
    {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% if( aSurveyInfo.surveyls_language  == "it") %}
    {{ image( "./files/logo_it_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% if( aSurveyInfo.surveyls_language  != "fr" and aSurveyInfo.surveyls_language  != "it") %}
    {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% endif %}

Alternative :
Code:
{{ image( "./files/logo_" ~ aSurveyInfo.surveyls_language ~ "_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
I like this one :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
5 years 10 months ago #190206 by tpartner

I don't think you have else if in twig :
twig.symfony.com/doc/2.x/tags/if.html

I see elseif:



But, yes, I like the last one too! It's more elegant. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
5 years 10 months ago #190219 by tschaipi
Well I still get a 500: internal server error (Unexpected end of template) with this code:
Code:
{# Logo language option #}
  {% if( aSurveyInfo.surveyls_language  == "de") %}
            <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_D_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
            </div>
  {% if( aSurveyInfo.surveyls_language  == "fr") %}
            <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_F_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
            </div>
  {% if( aSurveyInfo.surveyls_language  == "it") %}
            <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_I_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
            </div>
  {% endif %}

Any ideas?
The topic has been locked.
More
5 years 10 months ago - 5 years 10 months ago #190221 by DenisChenu
Need more endif
Code:
{% if( aSurveyInfo.surveyls_language  == "de") %}
        <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_D_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
        </div>
{% endif %}
{% if( aSurveyInfo.surveyls_language  == "fr") %}
        <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_F_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
        </div>
{% endif %}
{% if( aSurveyInfo.surveyls_language  == "it") %}
        <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {{ image( "./files/WBF_SBFI_I_RGB_pos_hoch.png", 'Logo', {"class": "logo img-responsive"}) }}
        </div>
{% endif %}

Else , seems elseif is OK, and NOT else if (thanks @tpartner)
Code:
{% if( aSurveyInfo.surveyls_language  == "fr") %}
    {{ image( "./files/logo_fr_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% elseif( aSurveyInfo.surveyls_language  == "it") %}
    {{ image( "./files/logo_it_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% else %}
    {{ image( "./files/logo_de_quer.png", 'anytext', {"class": "logo img-responsive"}) }}
{% endif %}

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
Last edit: 5 years 10 months ago by DenisChenu.
The following user(s) said Thank You: tschaipi
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose