Welcome to the LimeSurvey Community Forum

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

Toggle between templates based on language

  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
6 years 2 hours ago - 6 years 2 hours ago #167954 by LouisGac
Replied by LouisGac on topic Toggle between templates based on language
krosser: if you're a limeSurvey Pro user I can do it live for you
Last edit: 6 years 2 hours ago by LouisGac.
The topic has been locked.
More
6 years 2 hours ago #167957 by krosser
Replied by krosser on topic Toggle between templates based on language

LouisGac wrote: krosser: if you're a limeSurvey Pro user I can do it live for you


To do what, Louis? - Make nav_bar.twig visible in Bootswatch theme?

Do I have to open a new ticket in order to request it in the Pro account?

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
6 years 2 hours ago #167958 by LouisGac
Replied by LouisGac on topic Toggle between templates based on language
yep, would be perfect. I can do it today.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 11 months ago #168083 by tpartner
Replied by tpartner on topic Toggle between templates based on language
Here is an example of how to use an IF statement to render a language-dependent logo image:

Code:
{# Logo option #}
{% if( aSurveyInfo.options.brandlogo == "on") %}
 
  <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {% if( aSurveyInfo.surveyls_language == "en") %}
      {{ image('./files/logo_en.png', 'English logo', {"class": "logo-en"}) }}
    {% elseif( aSurveyInfo.surveyls_language == "fr") %}
      {{ image('./files/logo_fr.png', 'French logo', {"class": "logo-fr"}) }}
    {% else %}
      {{ image('./files/logo_default.png', 'Default logo', {"class": "logo-default"}) }}
    {% endif %}
  </div>
 
{% else %}
  <div class="{{ aSurveyInfo.class.navbarbrand }}"  {{ aSurveyInfo.attr.navbarbrand }} >
    {{ aSurveyInfo.name }}
  </div>
{% 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: krosser
The topic has been locked.
More
5 years 11 months ago #168100 by krosser
Replied by krosser on topic Toggle between templates based on language
Unfortunately, this code did not work for me. Tried it in Vanilla and Bootswatch and it does not show any logos.



Only this kind of code in nav_bar.twig works (but only in Vanilla and Fruity. In Bootswatch it shows both logos at the same time, one on top of the other)

Code:
<div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
                {#{{ image(aSurveyInfo.options.brandlogofile, aSurveyInfo.name, {"class": "logo img-responsive"}) }}#}
                {{ image('./files/logo-eng.png', 'alt-text for my file', {"class": "logo-en"}) }}
                {{ image('./files/logo-fr.png', 'alt-text for my file', {"class": "logo-fr"}) }}
            </div>

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 11 months ago #168103 by tpartner
Replied by tpartner on topic Toggle between templates based on language

Unfortunately, this code did not work for me. Tried it in Vanilla and Bootswatch and it does not show any logos.

It looks like you did not upload the images to the correct location or with the wrong names.

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 11 months ago #168106 by krosser
Replied by krosser on topic Toggle between templates based on language

tpartner wrote:

Unfortunately, this code did not work for me. Tried it in Vanilla and Bootswatch and it does not show any logos.

It looks like you did not upload the images to the correct location or with the wrong names.


Oh yes, sorry, you are right. I incorrectly wrote the file names (logo_eng.png instead of logo-eng.png). My bad... :silly:
So, it works in both themes.

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
More
5 years 5 months ago - 5 years 5 months ago #177376 by rikatechdoku
Replied by rikatechdoku on topic Toggle between templates based on language

tpartner wrote: Here is an example of how to use an IF statement to render a language-dependent logo image:

Code:
{# Logo option #}
{% if( aSurveyInfo.options.brandlogo == "on") %}
 
  <div class="{{ aSurveyInfo.class.navbarbrand }} logo-container hidden-xs"  {{ aSurveyInfo.attr.navbarbrand }}  >
    {% if( aSurveyInfo.surveyls_language == "en") %}
      {{ image('./files/logo_en.png', 'English logo', {"class": "logo-en"}) }}
    {% elseif( aSurveyInfo.surveyls_language == "fr") %}
      {{ image('./files/logo_fr.png', 'French logo', {"class": "logo-fr"}) }}
    {% else %}
      {{ image('./files/logo_default.png', 'Default logo', {"class": "logo-default"}) }}
    {% endif %}
  </div>
 
{% else %}
  <div class="{{ aSurveyInfo.class.navbarbrand }}"  {{ aSurveyInfo.attr.navbarbrand }} >
    {{ aSurveyInfo.name }}
  </div>
{% endif %}


This code works well for me most of the time (on the normal survey pages), but not during the registration form or enter-token form (and maybe more of these special forms?).

Does anyone have the same problems? Fixes, work-arounds, ideas? Many thx. Regards. S.

I'm using the hosted LimeSurvey Pro version (at least 3.15) on LS servers, AND also the locally installed xampp version as well (at least 3.15).
Last edit: 5 years 5 months ago by rikatechdoku.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 5 months ago - 5 years 5 months ago #177389 by tpartner
Replied by tpartner on topic Toggle between templates based on language
What version are you using? [strike]It does work for me in version 3.15.5.[/strike]

[EDIT] After further testing, there is a bug - bugs.limesurvey.org/view.php?id=14282 [/EDIT]

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 5 months ago by tpartner.
The topic has been locked.
More
5 years 5 months ago - 5 years 5 months ago #177407 by rikatechdoku
Replied by rikatechdoku on topic Toggle between templates based on language
Thx, Tony, for testing and opening the ticket. Thx to all who worked on it.

Will the next version be updated for the pro version automatically or must I initiate the update manually?
Because the bug ticket says "fixed" but it is still not working with my current pro version (3.15.5).

I'm using the hosted LimeSurvey Pro version (at least 3.15) on LS servers, AND also the locally installed xampp version as well (at least 3.15).
Last edit: 5 years 5 months ago by rikatechdoku.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 5 months ago - 5 years 5 months ago #177411 by holch
Replied by holch on topic Toggle between templates based on language
As you can see, the fix has been committed to GIT yesterday. So of course it is not yet in the current version. It will be in the next update at the earliest.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 5 years 5 months ago by holch.
The topic has been locked.
More
5 years 5 months ago #177412 by rikatechdoku
Replied by rikatechdoku on topic Toggle between templates based on language
Update:
Thx Tony and Denis,
I am now using aSurveyInfo.languagecode instead of aSurveyInfo.surveyls_language.
Seems to work ok. Is there a danger about that which I should be aware of?
Thx & regards, S.

I'm using the hosted LimeSurvey Pro version (at least 3.15) on LS servers, AND also the locally installed xampp version as well (at least 3.15).
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose