Ad

Why My Variable Lost, After I Modified Pages In CMS Backend Editor

- 1 answer

Firstly, I have put to string variable in my homepage code section. Pls check my below screen shot. enter image description here

And then, After I open it in my backend system.. When I hit the save button, mainNavClass = "dark transparent stick-fixed" topSpacing = "pt-0" are totally lost, is that filter function newly update feature? Or it's just my setting error? Please advice, Thanks.

enter image description here

Ad

Answer

We can not put direct variables there, as its reserved for the CMS it self for its variables and dynamic field variables. [ plus plugin component settings ]

Solution

you can add your variables in code section

function onStart() {
   $this['mainNavClass'] = 'dark transparent stick-fixed';
   $this['topSpacing'] = 'pt-0';    
}

enter image description here

Problem was

As its space CMS in-build fields and fields which we extend, there for CMS stores url, metadata info etc ... so when you save page it will override that portion with its data and it has no clue you added variables there so it will just rewrite all stuff all again so your data will be lost

enter image description here

it stores page field data and data related to added plugin components

if any doubts please comment.

Ad
source: stackoverflow.com
Ad