Disable default section (WEB)

Hi All,

I’m currently trying to work out how I can show a specific section in the web context. I currently have this as a control script:

if (merge.context.type == ContextType.WEB) {
//merge.section[‘default Section’].enabled = false;
merge.context.sections.PersonalDetails.enabled = record.fields.navigation == ‘’;
merge.context.sections.Question1.enabled = record.fields.navigation == ‘1’;
merge.context.sections.Thankyou.enabled = record.fields.navigation == ‘2’;

I would expect the commented out line to work but it doesn’t and courses an error. Any ideas? By the way, I only ever see the section that is set to default section.

Thanks

J

Hello John,

You have it as merge.section but it should be merge.sections. Possibly that’s the only reason, that little typo?

~Evie

Thank you Evie,

Unfortunately this isn’t just a typo. I have corrected the sections but still no go. The error I get is cannot set property “enabled” of undefined to false. My conclusion is that it doesn’t understand what the default section is. Currently the line I have set is:

merge.context.sections[‘default Section’].enabled = false;

Thanks

Ah, I think I understand what happens. There is no such thing as “default Section” unless you actually have a section that is literally called default Section. This isn’t a smart heuristic language, it’s a literal call to a section name.

Do you have any section that is named differently than PersonalDetails, Question1 and Thankyou? If you do, you’ll have to manually disable those sections one by one. If you don’t, then that line that doesn’t work is completely unnecessary in your script.

~Evie

Thanks Evie,

I seem to be asking the wrong questions. Here’s my script now:

if (merge.context.type == ContextType.WEB) {
merge.context.sections.PersonalDetails.enabled = false;
merge.context.sections.Question1.enabled = false;
merge.context.sections.Thankyou.enabled = false;
}

There are only three sections in this template. Whenever I create web sections, one of them will always be default. The control script above is disabling all the pages so there should be nothing to display. However, when I browse to the website, the section that is set to default is visible.

So, how do I disable the default section so that my script will do something?

Thanks

John

John,

If you disable all three sections, Connect will most definitely display the default section otherwise it would have nothing to show, which of course is not what you want.

Unless there’s an issue in the software that I’m not aware of, having only one section enabled should only show that section.

Perhaps the issue that you’re actually having though is that the script in your initial post wouldn’t work. I wasn’t 100% sure of this, but a bit of research does confirm that doing = something == ‘something’; would NOT work to establish a true or false condition. What you’re looking for is a shorthand IF condition in JavaScript. This would work :

merge.context.sections.PersonalDetails.enabled = (record.fields.navigation == ‘’) ? false : true;

What’s between the parentheses is the condition, between ? and : is “what to return when the condition is true”, and after that is “what to return when the condition is false”.

Hope this helps,
~Evie

Hi Evie,

I think there’s an issue in the software that you’re not aware of. I now have two of the sections set to …enabled = false and the third set to …enabled = true but the section that is visible when I browse to the website is always the section that is set to default, even though the page that is set to default is not enabled.

I’m currently trying to escalate this through UK support but I don’t think they understand the issue yet.

Thanks

John

I think it will be easier with the tech support team, especially if they have the actual template in hand that they can see and test themselves.

~Evie