Can we display the TOKEN value for the user?

More
6 months 1 week ago #217935 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!
 

Please Log in to join the conversation.

More
6 months 1 week ago #217940 by tpartner
If in a twig file, try:

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

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

More
6 months 1 week ago #217941 by cheeseburger
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!

Please Log in to join the conversation.

More
6 months 1 week ago #217942 by cheeseburger
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

Please Log in to join the conversation.

More
6 months 1 week ago #217946 by DenisChenu
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.

Please Log in to join the conversation.

More
6 months 1 week ago #218072 by LoyolaBehLAB
maybe you can use:

{if(is_empty(token.NAOK),rand(0,9999999),token.NAOK)}

Please Log in to join the conversation.

More
6 months 6 days ago - 6 months 6 days ago #218081 by tpartner
ExpressionScript if() statements will not work in TWIG files.

I think you need something like this:

{% 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: 6 months 6 days ago by tpartner.

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now