0

I'm having the same issue as described below, however can't find a solution:

Using Focus Lab's Master Config, I've set a test global variable for production, like so:

$env_global['global_test'] = 'test'; Then in an embedded template I've dropped in {global_test}. Also tried it in a non-embedded template.

In both cases the output, regardless of environment, is this;

{global_test} Am I missing something here?

source: (Why wouldn't global variable parse correctly with Master Config?)

In addition, these standard Focus Labs global variables don't work either: {global:env} {global:env_full}

I don't think it's caused by my server environment, as I have a 2nd separate site (EE 2.6.1) where it works fine, and I've tested on localhost and stage.mydomain.com

I'm guessing it's caused by a conflict with an Add-on... I'm using a long list including Stash, CE String, CE Image, Store, Low Variables, Matrix, Assets, Wygwam, Freeform, User, Taxonomy...

My site is running EE 2.6.1

Has anyone else come across and solved this issue before?

I'd be grateful for some guidance.

Many Thanks

EDIT:

Ok. I've figured out one problem...

I'd used the two standard Focus Labs variables {global:env} and {global:env_full} in an early parsed Low Variable. I guess the reason they weren't parsing has to do with parse order. They work fine, if added directly into a template.

That still leaves me struggling to set my own custom variable in config.local.php

This doesn't work:

$env_global['global:google_analytics'] = 'UA-XXXXXXX-XX';

Whereas this does:

global $assign_to_config; $assign_to_config['global_vars'] = array('global:google_analytics'  => 'UA-XXXXXXX-XX');
  • Can you post a section of your environment file where you are setting the variable? Are you sure you're setting the variable in the correct environment file? – Jeremy Gimbel Oct 9 '13 at 19:45
  • I'm certain I'm setting it in the right environment. I'll edit my post with more info... – Andrew F Oct 9 '13 at 19:54
  • Ok. I've solved it. It was a typo in the config.master.php – Andrew F Oct 9 '13 at 21:27
  • It happens to the best of us. Can you post your solution as an answer and accept it? – Jeremy Gimbel Oct 10 '13 at 1:25
  • Hi Jeremy, Do you think it's worth keeping this post, as I'm not sure if it'll be of use to anyone else. Thanks. – Andrew F Oct 10 '13 at 7:23
0

The main cause of my problem was a self-made accidental typo in config.master.php

I'd inadvertently added 'cce' to $assign_to_config (no idea when or how)

Wrong:

global $accessign_to_config;
if( ! isset($assign_to_config['global_vars']))
{
    $assign_to_config['global_vars'] = array();
}

Right:

global $assign_to_config;
if( ! isset($assign_to_config['global_vars']))
{
    $assign_to_config['global_vars'] = array();
}

So with that solved, my global variables still weren't parsing inside of Low Variables. There might be an alternative solution, however this worked for me:

An early-parsed Low Variable containing the preparse parameter

In my template:

{exp:low_variables:single
var="lv_google_analytics"
preparse:tracking_code="{global:google_analytics}"
}

The Low Variable: lv_google_analytics

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '{tracking_code}']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.