Welcome to the LimeSurvey Community Forum

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

Can we display the TOKEN value for the user?

  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 8 months ago #217935 by cheeseburger
Can we display the TOKEN value for the user? was created by cheeseburger
Hi, In previous versions (or previous ways in which we had used LS) we were able to display the TOKEN since it was in the address bar and we simply extracted that portion of the URL string. We no longer are configuring the survey to display the token within the address bar but would like to display it for the user (a specific business requirement from the client) using something like {TOKEN:TOKEN} but any syntax we try doesn't seem to parse the tag. We would be placing this in something like MAINROW.TWIG that we edit through the control panel. The content would be persistent across all screens in the survey (we paginate this survey into 20 screens). We aren't sure if it requires something like {% aSurveyInfo blah blah blah %} or {{ aSurveyInfo }} or some version like that but tried many and can't seem to produce the TOKEN value. 

Some info:
LimeSurvey Version 3.27.1
Survey is NOT anonymous 
Survey is activated and token based response persistence is set to ON

Thanks for any help!
 
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 8 months ago #217940 by tpartner
Replied by tpartner on topic Can we display the TOKEN value for the user?
If in a twig file, try:

Code:
{{ processString('{TOKEN:TOKEN}') }}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 8 months ago #217941 by cheeseburger
Replied by cheeseburger on topic Can we display the TOKEN value for the user?
Tony, I can't believe it! I finally thought processString would work for something that it actually did work for! This was perfect. Thank you!

Most of my previous posts always reference processString() so I hesitated trying it or asking about it again hahahaha. Thanks again!
The topic has been locked.
  • cheeseburger
  • cheeseburger's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 8 months ago #217942 by cheeseburger
Replied by cheeseburger on topic Can we display the TOKEN value for the user?
Do you know if it's possible to incorporate this into a condition? For example, if the token is defined then show some content, else do not show the content.

I tried some methods but am getting errors.

Thanks
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 8 months ago #217946 by DenisChenu
Replied by DenisChenu on topic Can we display the TOKEN value for the user?
TOKEN are set if SURVEY have token and are not anonymous.

Then : no real condition because it's a survey behaviour.

I don't understand …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
2 years 8 months ago #218072 by LoyolaBehLAB
Replied by LoyolaBehLAB on topic Can we display the TOKEN value for the user?
maybe you can use:

{if(is_empty(token.NAOK),rand(0,9999999),token.NAOK)}
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 8 months ago - 2 years 8 months ago #218081 by tpartner
Replied by tpartner on topic Can we display the TOKEN value for the user?
ExpressionScript if() statements will not work in TWIG files.

I think you need something like this:

Code:
{% if( processString('{TOKEN:TOKEN}')|trim != '' ) %}
processString('{TOKEN:TOKEN}')
{% else %}
'Some other text'
{% endif %}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 2 years 8 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose