Welcome to the LimeSurvey Community Forum

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

Twig theme: Targeting certain pages e.g. Welcome.

  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 10 months ago #184460 by jelo
Is it possible to hide e.g. certain parts of layout_global.twig when e.g. the welcome page is displayed?
Or a certain question?

The logic would be "If not welcomepage then display ... <DIV>...</DIV>".

Is there an example to learn from?

Thanks in advance.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 10 months ago #184473 by DenisChenu
Replied by DenisChenu on topic Twig theme: Targeting certain pages e.g. Welcome.
You can use aSurveyInfo.include_content twig variable to know what content ar loaded.

For question : it's same content, i don't see how to hide specific part except with js /css related to this question.

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.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 10 months ago #184481 by jelo

DenisChenu wrote: For question : it's same content, i don't see how to hide specific part except with js /css related to this question.

The simplest approach would be to have a modified layout_global.twig for the welcome page and the untouched one for every other page.

A let me ask the question in a different way:
How can the "layout_global.twig" become flexible, to e.g. hide a div-section on the welcome page only. If I got you right, the TWIG "if" won't help me when it comes to page context? But the options of themes work in the same way, when it comes to hiding/showing parts.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 10 months ago - 4 years 10 months ago #184503 by tpartner
I use something like this in layout_global.twig to target different pages:

Code:
{% if (aSurveyInfo.aNavigator.show and aSurveyInfo.include_content == 'firstpage')  %}
    <!-- Do something in the Welcome page -->
{% endif %}     
 
{% if (aSurveyInfo.aNavigator.show and aSurveyInfo.include_content != 'firstpage')  %}
    <!-- Do something in question pages -->
{% endif %}    
 
{% if (aSurveyInfo.aNavigator.show == null)  %}
    <!-- Do something in the End page -->
{% endif %}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 10 months ago by tpartner.
The topic has been locked.
  • jelo
  • jelo's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
4 years 10 months ago #184506 by jelo

tpartner wrote: I use something like this in layout_global.twig to target different pages:

That is the approach I was looking for. Thanks.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 10 months ago #184508 by DenisChenu
Replied by DenisChenu on topic Twig theme: Targeting certain pages e.g. Welcome.

jelo wrote:

DenisChenu wrote: For question : it's same content, i don't see how to hide specific part except with js /css related to this question.

The simplest approach would be to have a modified layout_global.twig for the welcome page and the untouched one for every other page.

A let me ask the question in a different way:
How can the "layout_global.twig" become flexible, to e.g. hide a div-section on the welcome page only. If I got you right, the TWIG "if" won't help me when it comes to page context? But the options of themes work in the same way, when it comes to hiding/showing parts.

layout_global is loaded …

You can't disable this …

BUT :
There are way to extend it …

1. Create a new layout_default.twig (copy of current BUT with more block )
2. Delete whole in layout_global to put
Code:
{% if ( aSurveyInfo.include_content == 'firstpage')  %}
    {% include './layout_firstpage.twig'
{% else %}
    {% include './layout_default.twig'
{% endif %}

Your alternative layout can extend layout_default : gitlab.com/SondagesPro/SurveyThemes/skel..._survey_list.twig#L1

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 following user(s) said Thank You: tpartner
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose