Disable "Header Extra Content" in edit mode

Permalink
I've started using Google Experiments to do A/B testing in Concrete5. It requires you to add Google's Javascript code to the header of your page. I do this in the "Header Extra Content" property of the relevant pages. The only problem: the Javascript is also present in edit mode and thus also redirects you to one of the page variants when in edit mode.

Is there a standard way to "disable" the javascript in the "Header Extra Content" property in edit mode? If not, what would be the best way to solve this?

Thanks,

Pascal

plindelauf
 
JohntheFish replied on at Permalink Reply
JohntheFish
You can modify the script to do:
if (!CCM_EDIT_MODE){
  // existing javascript
}
plindelauf replied on at Permalink Reply
plindelauf
Thanks, John! I didn't know of the existence of the CCM_EDIT_MODE variable.

Even though you have exactly answered my question, I realize that my question wasn't 100% correct in the first place. That is, because I forgot that Concrete5 is not considered to be in edit mode when you login and go to a page. You actually need to "Edit Page" to go into edit mode. But then I still have the problem that when I navigate to a page when I'm logged in, the inserted Javascript redirects me to one of the page alternatives.

So my question should have been: how can I disable "Header Extra Content" when I'm logged in. Any idea?

And one other thing I found out: I tried adding a condition like this one:
if (document.getElementById("ccm-toolbar") !== null) { return false; }


But it seems Google doesn't like this modification of the script. So ideally, there would be a PHP-based in- and exclusion mechanism for the "Header Extra Content".
JohntheFish replied on at Permalink Reply
JohntheFish
For that, you need to override the core
concrete/elements/header_required.php

The extra content is output at the end of the element file.

You would want to wrap it in a test along the lines of
if(!$u->isSuperUser()){
  echo ....;
}


There are other user tests you can do on the user and permissions, the above would be just to ignore you.