Welcome, Guest
Username: Password: Remember me

TOPIC: Language detection in template files

Language detection in template files 2 years 7 months ago #73436

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
I want to use a different logo, depending on the language. Is there a way to display a logo conditionally? Something like

<img src="/images/{if(LANGUAGE=='en','en_logo','other_logo')}.png" />

Except I don't think there's a keyword LANGUAGE.

Gracias,

Tac
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73454

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
It might be possible by adjusting this workaround: docs.limesurvey.org/The+template+editor&...age_specific_element

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73472

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
Thanks -- what are the better solutions in 1.92? I'm guessing Expression Manager gives us a bit more power. The old way of writing javascript to customize a question never felt right, but the new way is quite elegant.
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73474

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
There is a {LANG} keyword, so you could do this:
<img src="/images/{if(LANG=='en','en_logo','other_logo')}.png" />

or, since you should know all possible languages your survey uses:
<img src="/images/{LANG}_logo.png" />
The administrator has disabled public write access.
The following user(s) said Thank You: tacman1123

Re: Language detection in template files 2 years 7 months ago #73478

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
Perfect, thanks! Where are the keywords documented? I found the if() syntax while looking at something else, is there more documentation on what the template language can do, like loops or more sophisticated if structures, like Smarty or Twig?

I'm a big fan of both Smarty and Twig, and would be thrilled if LS2.0 consider using them. They're quite fast and have great support.
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73481

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
Tom, I couldn't find the {LANG} keyword at one of those lionks:
docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords
docs.limesurvey.org/Expression+Manager+H...tions+for+LimeSurvey
docs.limesurvey.org/Expression+Manager+f...tions+for+LimeSurvey

...but I remember you once created a keyword overview. Is this still available and do you think we can place that somewhere else at the manual so that users know which placeholders they can deal with?

@tacman: We are now moving all code to the MVC framework "Yii" for the Limesurvey 2.0 release so such thing is not on the list yet but we hope to lay the basics for it this way.
You can add this as a feature request at our feature tracker . Please describe your idea as detailed as possible and try to outline a suitable solution/implementation as well.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73498

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Here is the list of keywords from the last analysis I did. Someone should update the documentation to list any missing ones.

As to documentation about the if() syntax, etc., there is an EM button within 1.92 under survey-specific tools that generates a table of all of the supported functions and their documentation. This table in the main EM documentation should also be up-to-date.
The administrator has disabled public write access.

Re: Language detection in template files 2 years 7 months ago #73513

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
Can we somehow make the list of keywords a little smaller so that it is easier to read and easier to embedd at the documentation?
Maybe separate it into sections (template placeholders, token placeholders, ...)?

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.244 seconds
Donation Image