Welcome to the LimeSurvey Community Forum

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

Different Logo for Different Language

  • benjaminschlegel
  • benjaminschlegel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 months ago - 6 years 2 months ago #163957 by benjaminschlegel
Different Logo for Different Language was created 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: 6 years 2 months ago by benjaminschlegel.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #163966 by tpartner
Replied by tpartner on topic Different Logo for Different Language
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.
  • benjaminschlegel
  • benjaminschlegel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 2 months ago - 6 years 2 months ago #163968 by benjaminschlegel
Replied by benjaminschlegel on topic Different Logo for Different Language
Thanks a lot, that worked!
Last edit: 6 years 2 months ago by benjaminschlegel.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 2 months ago #163978 by tpartner
Replied by tpartner on topic Different Logo for Different Language
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
4 years 5 months ago #190192 by tschaipi
Replied by tschaipi on topic Different Logo for Different Language
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.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190193 by DenisChenu
Replied by DenisChenu on topic Different Logo for Different Language
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 service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190206 by tpartner
Replied by tpartner on topic Different Logo for Different Language

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
4 years 5 months ago #190219 by tschaipi
Replied by tschaipi on topic Different Logo for Different Language
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.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago - 4 years 5 months ago #190221 by DenisChenu
Replied by DenisChenu on topic Different Logo for Different Language
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 service on demand , plugin development .
I don't answer to private message.
Last edit: 4 years 5 months ago by DenisChenu.
The following user(s) said Thank You: tschaipi
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose