Global variables

edited August 2015 in Share
We use a set of constants for various bits of information in our sites so if we need to use a constant within a Fuelified page or block we then turn that constant into a variable using the global file (application/views/_variables/global.php) like so:

$vars['secure_base_url'] = SECURE_BASE_URL;

And then use it where we need to, like this example:

<a href="<?=url('register', $secure_base_url)?>" class="button" />Join Now</a>

But though we have used this successfully in other sites in our system that are similar I'm currently getting an "undefined variable" error. Any idea what could be causing this?

Comments

  • edited 12:41AM
    How is that page getting rendered (e.g. from a controller, the CMS, or a view without a controller)? If you use a controller, you will need to use $this->fuel->pages->render('path/to/uri') to have the global variables file loaded.
  • edited 12:41AM
    Ok great. So any time we use a controller (and want the global variables to be included) we include this in the controller then right?
  • edited 12:41AM
    You need to render the page that way for it to assemble all the variables and views together.
Sign In or Register to comment.