Welcome to the LimeSurvey Community Forum

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

Change the logo on the template based on Token Value

  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
4 years 3 months ago #191890 by davebostockgmail
Just wondering if it is possible to change the image shown as the logo depending on a value in a token attribute

I am working on a project where there are 5 brands from one company and I can identify each brand from the information they have given me.

What I would like to do is something along the lines of ...

if(TOKEN:ATTRIBUTE)=="1","Logo1.png", if(TOKEN:ATTRIBUTE)=="2","Logo2.png ...... etc. etc. etc.

Current Version is : Version 3.20.1+191114

And I am working with the following Theme : LimeSurvey Fruity Theme


If this is not possible in Limesurvey out of the box then any thoughts or ideas would be greatly welcomed.


Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago - 4 years 3 months ago #191897 by tpartner
You can use the processString() function in the theme twig files to access Expression Manager variables and token values.

Code:
"Logo{{ processString("{TOKEN:ATTRIBUTE_1}") }}.png"

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 3 months ago by tpartner.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191898 by tpartner
...or, if you need a default value:

Code:
{% set attribute1 = '1' %}   
{% if processString("{TOKEN:ATTRIBUTE_1}") != '' %}
    {% set attribute1 = processString("{TOKEN:ATTRIBUTE_1}") %}
{% endif %}
<img src="pathToImages/Logo{{ attribute1 }}.png" />

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • davebostockgmail
  • davebostockgmail's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
4 years 3 months ago #191899 by davebostockgmail
Replied by davebostockgmail on topic Change the logo on the template based on Token Value
Amazing

Thanks Tony
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose