- Posts: 54
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Only show specific question groups in navigation menu
- BBSR-SR5
- Topic Author
- Offline
- Senior Member
Less
More
3 weeks 5 days ago #259807
by BBSR-SR5
Only show specific question groups in navigation menu was created by BBSR-SR5
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 6.4.12
Own server or LimeSurvey hosting: LimeSurvey Cloud
Survey theme/template: Customised fruity23 blueberry template
==================
Hello everyone,
I'm trying to adjust my navigation menu/question index, so only specific question groups are shown. I'm using the question group after question group setting.
I want to use some flag to determine wether a question group should be shown or not.
I think to achieve this I need to adjust some code in the question_index_menu.twig. This would be the relevant code, I think:
To achieve this I figure the best way would be to put everything within the for-loop into some if clause that checks if a flag on the indexItem is set. Like this:
Could this work? And how could I attach some custom attribute to my question groups?
Or is there some other workaround I could chose?
Your LimeSurvey version: Version 6.4.12
Own server or LimeSurvey hosting: LimeSurvey Cloud
Survey theme/template: Customised fruity23 blueberry template
==================
Hello everyone,
I'm trying to adjust my navigation menu/question index, so only specific question groups are shown. I'm using the question group after question group setting.
I want to use some flag to determine wether a question group should be shown or not.
I think to achieve this I need to adjust some code in the question_index_menu.twig. This would be the relevant code, I think:
Code:
<div> {# TODO: move back this logic to SurveyRuntime, and provide a ready to use indexItem.statusClass #} {% for step, indexItem in aSurveyInfo.aQuestionIndex.items %} {% set statusClass = '' %} {% if attribute(indexItem.stepStatus, 'index-item-unanswered') is defined and attribute(indexItem.stepStatus, 'index-item-unanswered') == true %} {% set statusClass = statusClass ~ ' index-warning' %} {% endif %} {% if attribute(indexItem.stepStatus, 'index-item-error') is defined and attribute(indexItem.stepStatus, 'index-item-error') == true %} {% set statusClass = statusClass ~ ' index-danger' %} {% endif %} {% if attribute(indexItem.stepStatus, 'index-item-current') is defined and attribute(indexItem.stepStatus, 'index-item-current') == true %} {% set statusClass = statusClass ~ ' disabled' %} {% endif %} <li class="list-group-item {{ indexItem.coreClass }}"> <a href='{{ indexItem.url }}' data-limesurvey-submit='{{ indexItem.submit }}' class='dropdown-item {{ statusClass }}'> {{ indexItem.text }} </a> </li> {% endfor %} </div>
To achieve this I figure the best way would be to put everything within the for-loop into some if clause that checks if a flag on the indexItem is set. Like this:
Code:
{% if indexItem.showItem == 1 %} {#other code here#} {% endif %}
Could this work? And how could I attach some custom attribute to my question groups?
Or is there some other workaround I could chose?
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10110
- Thank you received: 3594
3 weeks 5 days ago - 3 weeks 5 days ago #259809
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Only show specific question groups in navigation menu
The only thing I can think of is appending the group title with that attribute, separated by some special character.
In question_index_menu.twig, you split the indexItem.text variable by the special character to access the attribute.
In group_name.twig, you split the aGroup.name variable by the special character to remove the attribute.
In question_index_menu.twig, you split the indexItem.text variable by the special character to access the attribute.
In group_name.twig, you split the aGroup.name variable by the special character to remove the attribute.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 weeks 5 days ago by tpartner.
Please Log in to join the conversation.
- BBSR-SR5
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 3
3 weeks 4 days ago #259831
by BBSR-SR5
Replied by BBSR-SR5 on topic Only show specific question groups in navigation menu
Thank you, I think that approach might be workable.
I figured it might be even easier to put an invisible character into the title using
But unfortunately this seems to get automatically turned into &zwnj and appears in the title of the question. Is there some way to put some invisible character/string into the group title, so I can simply search for that without needing to cut the title into parts?
I figured it might be even easier to put an invisible character into the title using
Code:
&zwnj
But unfortunately this seems to get automatically turned into &zwnj and appears in the title of the question. Is there some way to put some invisible character/string into the group title, so I can simply search for that without needing to cut the title into parts?
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13655
- Thank you received: 2492
3 weeks 4 days ago #259832
by DenisChenu
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.
Replied by DenisChenu on topic Only show specific question groups in navigation menu
I use # inside the hidden group title and use strpos to add the li or not.
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.
- BBSR-SR5
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 3
3 weeks 4 days ago #259845
by BBSR-SR5
Replied by BBSR-SR5 on topic Only show specific question groups in navigation menu
Thank you all for your advise. I've solved it by just adding a "#" (the character(s) are arbitrary. You can just choose whatever) at the end of the question group title. Since I'm not showing said titles this is only affecting the navigation menu/index.
I'm removing the "#" from the index entries like this: {{ indexItem.text|split('#')[0] }}
I'm removing the "#" from the index entries like this: {{ indexItem.text|split('#')[0] }}
Code:
{% for step, indexItem in aSurveyInfo.aQuestionIndex.items %} {% if '#' in indexItem.text %} {% set statusClass = '' %} {% if attribute(indexItem.stepStatus, 'index-item-unanswered') is defined and attribute(indexItem.stepStatus, 'index-item-unanswered') == true %} {% set statusClass = statusClass ~ ' index-warning' %} {% endif %} {% if attribute(indexItem.stepStatus, 'index-item-error') is defined and attribute(indexItem.stepStatus, 'index-item-error') == true %} {% set statusClass = statusClass ~ ' index-danger' %} {% endif %} {% if attribute(indexItem.stepStatus, 'index-item-current') is defined and attribute(indexItem.stepStatus, 'index-item-current') == true %} {% set statusClass = statusClass ~ ' disabled' %} {% endif %} <li class="list-group-item {{ indexItem.coreClass }}"> <a href='{{ indexItem.url }}' data-limesurvey-submit='{{ indexItem.submit }}' class='dropdown-item {{ statusClass }}'> {{ indexItem.text|split('#')[0] }} </a> </li> {% endif %} {% endfor %}
The following user(s) said Thank You: DenisChenu, tpartner
Please Log in to join the conversation.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13655
- Thank you received: 2492
3 weeks 4 days ago #259846
by DenisChenu
Great ! Thanks for the twig syntax !
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.
Replied by DenisChenu on topic Only show specific question groups in navigation menu
Code:
{% if '#' in indexItem.text %}
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.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10110
- Thank you received: 3594
3 weeks 4 days ago #259850
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Only show specific question groups in navigation menu
Yes, if you are after a binary attribute, this is a great way to handle it.I've solved it by just adding a "#" (the character(s) are arbitrary. You can just choose whatever) at the end of the question group title.
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.
- BBSR-SR5
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 54
- Thank you received: 3
3 weeks 3 hours ago #260084
by BBSR-SR5
Replied by BBSR-SR5 on topic Only show specific question groups in navigation menu
Now I'm trying to figure out how to do a completition indicator for my custom navigation menu.
In this case I need to do three things: Find out if a question/block is answered. Find out if a question is visible/not filtered. And then see if all visible questions from a # to the next # are answered.
I guess the first I can do with this code?
But how do I check if it/all questions in the block have been filtered or not?
In this case I need to do three things: Find out if a question/block is answered. Find out if a question is visible/not filtered. And then see if all visible questions from a # to the next # are answered.
I guess the first I can do with this code?
Code:
{% if attribute(indexItem.stepStatus, 'index-item-unanswered') is defined and attribute(indexItem.stepStatus, 'index-item-unanswered') == true %}
But how do I check if it/all questions in the block have been filtered or not?
Please Log in to join the conversation.