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

More
1 week 3 days 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

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
1 week 2 days ago #184473 by DenisChenu
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 .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
1 week 2 days 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

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago - 1 week 2 days ago #184503 by tpartner
I use something like this in layout_global.twig to target different pages:

{% 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.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 1 week 2 days ago by tpartner.

Please Log in or Create an account to join the conversation.

More
1 week 2 days 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

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #184508 by DenisChenu

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
{% 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 .
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: tpartner

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!