Welcome to the LimeSurvey Community Forum

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

Toggle between templates based on language

More
7 years 4 months ago #167726 by Joffm
Thanks, tpartner,
of course it's a template engine, where we can use the twig statements.
Though there is an "if" statement three lines above

{% if( aSurveyInfo.options.brandlogo == "on") %}

it didn't come to my mind to use it.

To be honest, I use a different template engine in my programs.
So I am not familiar with twig.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
7 years 4 months ago #167731 by krosser

tpartner wrote: No, you should not be doing anything with the core vanilla or bootswatch theme directories. They will be over-written on updating.

I am responding from my phone and memory this week so I may make some mistakes on the file structure but...

My understanding is that you have extended (copied) bootswatch. This should create a directory:

/upload/themes/survey/yourThemeName/

Now the theme dependency/inheritance ladder is:

- vanilla
- bootswatch
- yourThemeName


So, if you copy nav_bar.twig into...

/upload/themes/survey/yourThemeName/views/subviews/header/

...it will automatically override any copy of that file in the parent themes (bootswatch and vanilla).

You may not be able to see that new file in the template editor but any changes made in a plain-text editor and uploaded via FTP will be applied.


Can this be done when you use LS in their cloud and not installed on your server?

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
More
7 years 4 months ago #167732 by krosser

tpartner wrote: You can use an IF() statement in the twig file so only one image (depending on language) is loaded. This will reduce server load and browser load-time. I'll give an example next week when I get back to the world.


That would be nice! I look forward to your code example.

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
More
7 years 4 months ago #167740 by tpartner

Can this be done when you use LS in their cloud and not installed on your server?

I don't know. Contact support and ask there. As far as I am concerned all twig files that now replace the old .pstpl files should be available in the theme editor. (but maybe they are still working on that)

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
7 years 4 months ago #167858 by krosser

tpartner wrote:

Can this be done when you use LS in their cloud and not installed on your server?

I don't know. Contact support and ask there. As far as I am concerned all twig files that now replace the old .pstpl files should be available in the theme editor. (but maybe they are still working on that)


I have contacted them multiple times on different issues and they are always reluctant to provide extensive support or any feedback. Therefore, I have to seek help largely here on the forum.

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
More
7 years 4 months ago #167876 by holch
well, they are providing hosting for Limesurvey. Extensive support to customization of Themes/Templates isn't part of the support scope, I guess.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The topic has been locked.
More
7 years 4 months ago #167880 by tpartner
Yes but my statement "all twig files that now replace the old .pstpl files should be available in the theme editor" still stands. In other words, if it was previously possible to edit an element in the GUI, it should still be possible.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • New Member
  • New Member
More
7 years 4 months ago #167910 by LouisGac
Replied by LouisGac on topic Toggle between templates based on language

tpartner wrote: Yes but my statement "all twig files that now replace the old .pstpl files should be available in the theme editor" still stands. In other words, if it was previously possible to edit an element in the GUI, it should still be possible.


yes we should add a new "screen" with all twig files.


For now, if you want to add a twig file in the ThemeEditor list:


1. Open the config.xml of your theme.
2. In the engine>template_editor section
3. Find the screen that interest you. For exemple, for the welcome page:
github.com/LimeSurvey/LimeSurvey/blob/b3...config.xml#L119-L137

4. Here, just add the twig files you want. For example:
Code:
<file type="view" role="subview">./subviews/navigation/clearall_links.twig</file>
The topic has been locked.
More
7 years 4 months ago - 7 years 4 months ago #167911 by krosser

LouisGac wrote:

tpartner wrote: Yes but my statement "all twig files that now replace the old .pstpl files should be available in the theme editor" still stands. In other words, if it was previously possible to edit an element in the GUI, it should still be possible.


yes we should add a new "screen" with all twig files.


For now, if you want to add a twig file in the ThemeEditor list:


1. Open the config.xml of your theme.
2. In the engine>template_editor section
3. Find the screen that interest you. For exemple, for the welcome page:
github.com/LimeSurvey/LimeSurvey/blob/b3...config.xml#L119-L137

4. Here, just add the twig files you want. For example:
Code:
<file type="view" role="subview">./subviews/navigation/clearall_links.twig</file>


So do you have to export, modify and import the theme back to make it work?
I tried to manually add nav_bar.twig to the exported theme and import it back and it didn't work for me. I changed the name of the archive and in the config.xml too. The theme then doesn't appear in the list and aftwerwards doesn't allow to import again saying that it's already there.

In general, why don't we have nav_bar.twig in the list in Bootswatch by default if it's there but not visible?

I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Last edit: 7 years 4 months ago by krosser.
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • New Member
  • New Member
More
7 years 4 months ago - 7 years 4 months 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: 7 years 4 months ago by LouisGac.
The topic has been locked.
More
7 years 4 months ago #167957 by krosser

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
  • New Member
  • New Member
More
7 years 4 months 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.
More
7 years 3 months ago #168083 by tpartner
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
7 years 3 months ago #168100 by krosser
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.
More
7 years 3 months ago #168103 by tpartner

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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose