- Posts: 2
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Toggle between templates based on language
- taswell
- Topic Author
- Offline
- New Member
Less
More
6 years 11 months ago #155039
by taswell
Toggle between templates based on language was created by taswell
Hello,
I have a survey in English and French. I want to toggle between the template, to change the logo, based on which language is selected. Is that possible to do?
I have a survey in English and French. I want to toggle between the template, to change the logo, based on which language is selected. Is that possible to do?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 11 months ago #155041
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Toggle between templates based on language
You should be able to do that with CSS if you give the logo images language-specific classes.
Code:
body.lang-en img.logo-fr { display: none; } body.lang-fr img.logo-en { display: none; }
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 5 days ago - 6 years 5 days ago #167656
by krosser
I need to do the same - be able to change the logo images between languages - and I can't get this code to work. Should the code differ for the LS 3.6-3.7?
I wonder why you gave the opposite languages to logos in your script? - en to fr and fr to en...
I tried it in Vanilla and Bootswatch themes.
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
tpartner wrote: You should be able to do that with CSS if you give the logo images language-specific classes.
Code:body.lang-en img.logo-fr { display: none; } body.lang-fr img.logo-en { display: none; }
I need to do the same - be able to change the logo images between languages - and I can't get this code to work. Should the code differ for the LS 3.6-3.7?
I wonder why you gave the opposite languages to logos in your script? - en to fr and fr to en...
I tried it in Vanilla and Bootswatch themes.
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Last edit: 6 years 5 days ago by krosser.
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 5 days ago #167659
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
If anyone can help figure out how to implement the logo switch between languages, please reply.
The manual only describes how to add your own logo but has nothing on 2+ logos for one survey in different languages.
Thanks in advance!
The manual only describes how to add your own logo but has nothing on 2+ logos for one survey in different languages.
Thanks in advance!
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 4 days ago #167688
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
Tony, I've realised why you have opposite languages in the code - to hide the English logo when the page is in French and the other way round.
As I understand, I need to have both logos loaded when I run the survey in order to do so. But the theme allows to choose one logo at a time. I've tried to change the .twig file, like it's described in " Adding your own logo to the survey list (New in 3.0 ) " but changing the name of the png file in line 126 to my logo's name didn't make a difference. Perhaps, I should add the second image in the twig file?
As I understand, I need to have both logos loaded when I run the survey in order to do so. But the theme allows to choose one logo at a time. I've tried to change the .twig file, like it's described in " Adding your own logo to the survey list (New in 3.0 ) " but changing the name of the png file in line 126 to my logo's name didn't make a difference. Perhaps, I should add the second image in the twig file?
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12940
- Thank you received: 3979
6 years 4 days ago #167690
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Toggle between templates based on language
Hi, krosser,
I entered this in "navbar.twig"
{{ image('./files/myFirstImage.png', 'alt-text for my file', {"class": "logo-en"}) }}
{{ image('./files/mySecondImage', 'alt-text for my file', {"class": "logo-fr"}) }}
And it changes dynamically after changing the language by Languagechanger.
If the logo is somewhere else, other twig-file.
I entered this in "navbar.twig"
{{ image('./files/myFirstImage.png', 'alt-text for my file', {"class": "logo-en"}) }}
{{ image('./files/mySecondImage', 'alt-text for my file', {"class": "logo-fr"}) }}
And it changes dynamically after changing the language by Languagechanger.
If the logo is somewhere else, other twig-file.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: krosser
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 4 days ago - 6 years 4 days ago #167691
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
Many thanks, Joffm, for the suggestion! I will try to reproduce what you did.
Can you please specify in which theme you did this (Fruity or Vanilla) and also in which line you added the code (any specific or at the end of the .twig)?
Also, I wonder if you just specified the logos uploaded through theme editor? Which one of them did you specify in the settings of the survey?
FYI, I'm working mostly in Bootswatch theme now, as it suits our design needs more than the others.
Can you please specify in which theme you did this (Fruity or Vanilla) and also in which line you added the code (any specific or at the end of the .twig)?
Also, I wonder if you just specified the logos uploaded through theme editor? Which one of them did you specify in the settings of the survey?
FYI, I'm working mostly in Bootswatch theme now, as it suits our design needs more than the others.
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Last edit: 6 years 4 days ago by krosser.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12940
- Thank you received: 3979
6 years 4 days ago - 6 years 4 days ago #167693
by Joffm
I commented the original line of the brandlogo and added these two behind.
About line 35.
And it's about the same line in fruity.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Toggle between templates based on language
Sorry, this was in "vanilla".Can you please specify in which theme you did this (Fruity or Vanilla) and also in which line you added the code (any specific or at the end of the .twig)?
I commented the original line of the brandlogo and added these two behind.
About line 35.
And it's about the same line in fruity.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 4 days ago by Joffm.
The following user(s) said Thank You: krosser
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 4 days ago - 6 years 4 days ago #167697
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
So, I could reproduce what you did and make it work too - in Vanilla.
But in Bootswatch theme I cannot find where the logo is. There is no nav_bar.twig and I've searched all other twig files. What do you think I should do for this theme?
EDIT: I've just found that someone else had this issue with nav_bar.twig in Bootswatch.. although he didn't get a reply.
But in Bootswatch theme I cannot find where the logo is. There is no nav_bar.twig and I've searched all other twig files. What do you think I should do for this theme?
EDIT: I've just found that someone else had this issue with nav_bar.twig in Bootswatch.. although he didn't get a reply.
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Last edit: 6 years 4 days ago by krosser.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12940
- Thank you received: 3979
6 years 4 days ago #167700
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Toggle between templates based on language
Hi,
you only asked about "fruity" and "vanilla".
I deliberately did not write anything about "bootswatch". This seems to be something different.
I am not very successful in adapting this theme.
Therefore I stay to vanilla at the moment.
And the other thread? There was the question about the visibility of some twig files, which are visible in "fruity" but not in "bootswatch".
I think there was no answer, because nobody knows why these files are not published. (It's not a bug, it's a feature)????
Hopefully somebody extends the manual about the new theme options and theme editor.
Joffm
you only asked about "fruity" and "vanilla".
I deliberately did not write anything about "bootswatch". This seems to be something different.
I am not very successful in adapting this theme.
Therefore I stay to vanilla at the moment.
And the other thread? There was the question about the visibility of some twig files, which are visible in "fruity" but not in "bootswatch".
I think there was no answer, because nobody knows why these files are not published. (It's not a bug, it's a feature)????
Hopefully somebody extends the manual about the new theme options and theme editor.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- krosser
- Offline
- Elite Member
Less
More
- Posts: 222
- Thank you received: 10
6 years 4 days ago #167702
by krosser
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
Replied by krosser on topic Toggle between templates based on language
It's okay, Joffm. I'm learning and that is why I'd like to know how it's done in all 3 default themes. Otherwise, I won't be able to do anything. So, I appreciate that you helped me figure out how it's done in Vanilla and Fruity! I can't thank you enough.
As my team liked Bootswatch's design more, I just wanted to stick to it and adjust to our needs.
I can see that this forum is read by the LS team members. So, perhaps, they can chime in and explain how the logo switch is done in Bootswatch...
As my team liked Bootswatch's design more, I just wanted to stick to it and adjust to our needs.
I can see that this forum is read by the LS team members. So, perhaps, they can chime in and explain how the logo switch is done in Bootswatch...
I'm using the latest LS 3.22 hosted on LS servers, not installed locally.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
6 years 4 days ago #167704
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Toggle between templates based on language
Copy nav_bar.twig to your extended theme directory (using the same file structure as that in vanilla). Then changes in that file will apply regardless of theme dependencies.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.