Welcome to the LimeSurvey Community Forum

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

Keep token linked info (attributes) when changing language in survey

More
23 hours 27 minutes ago #272813 by dvilchez
Your LimeSurvey version: 6.15.16
Own server or LimeSurvey hosting: Lime survey Hosting
Survey theme/template: Fruity

Hi there,I’ve built quite a complex survey in LimeSurvey. It’s multilingual and restricted to a specific group of participants. For some conditional questions, I use attributes from the participant table (e.g.,
Code:
TOKEN:ATTRIBUTE_1 = 1
) so the survey doesn’t need to ask for information I already have.The issue is that when I start the survey and switch languages using the top-menu language switcher, the attribute information disappears. Apparently this happens because the URL changes from one that includes the token (e.g.: xxxxxx.limequery.org/376147?token=fuab_202500000a&newtest=Y ) to a generic URL without it ( xxxxxx.limequery.org/376147 ) .I got some JavaScript from an AI chat that was supposed to fix the problem, but it doesn’t. The code is intended to be placed in 
Code:
language_changer_top_menu.twig
.{# Capture all current query parameters #}
{% set q = app.request.query.all %}

{# (Optional) list of parameters you want to explicitly preserve #}
{% set keep = %}

{# When rendering each language option #}
<ul class="dropdown-menu languagechanger">
  {% for langcode, langname in aSurveyInfo.aOtherLanguages %}
    {# Merge current query parameters with the new 'lang' value #}
    {% set q2 = q|merge({'lang': langcode}) %}
    <li>
      <a class="ls-language-link"
         href="{{ app.request.pathInfo }}?{{ q2|url_encode('query') }}">
         {{ langname }}
      </a>
    </li>
  {% endfor %}
</ul>

How can I prevent the problem?
Is in the snippet any mistake?

Thanks!! 

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose