Making variable available in blocks?

edited May 2015 in Share
So we're still on 0.9.3 in this particular project. We have a constant that we want to be able to use once we have Fuelified a page. So we added it to the globals.php file in _variables like so:

$vars['secure_base_url'] = SECURE_BASE_URL;

This seems to work fine in our other system that uses 1.1 but it seems that the CI instance is not loaded automatically in blocks in 0.9.3? So when I try to use this variable in a block it throws an undefined variable error.

What's the best way to fix this?

Comments

  • edited 7:52AM
    You can add the following inside your blocks:
    $CI =& get_instance();
    Also, is the following in your globals.php variables file?
    $vars['CI'] =& get_instance();
  • edited 7:52AM
    The upper code block is what we have in our globals file. I added it directly to the top block itself:

    <?php $CI =& get_instance(); ?>

    It still isn't working. What am I doing wrong?
  • edited 7:52AM
    How are you accessing the variable in your block? Is it just:
    <?=$secure_base_url?>
  • edited May 2015
    <a href="<?=url('register', $secure_base_url)?>" class="button large" />Join</a>
  • edited 7:52AM
    Is that variable set if you do the following:
    $CI =& get_instance(); <a href="<?=url('register', $CI->get_var('secure_base_url');?>" class="button large" />Join</a>
  • edited 7:52AM
    No it still says there is an undefined variable.
  • edited 7:52AM
    Is this page being rendered by a controller by chance?
  • edited 7:52AM
    That might be the problem. Chatting with a coworker and will get back to you. Thanks for your help so far!
Sign In or Register to comment.