ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Setting global variables

January 19, 2011 2:17pm

Subscribe [2]
  • #1 / Jan 19, 2011 2:17pm

    Mark Croxton

    319 posts

    In EE 1.x I was able to create global variables in path.php by putting them in the $global_vars array:

    $global_vars['my_variable_key'] = 'whatever';

    I could then access them in my templates with {my_variable_key}

    I’d like to do the same in EE 2.x. Can you tell me how?

    Many thanks

    Mark

  • #2 / Jan 20, 2011 3:32am

    Ingmar

    29245 posts

    In your index.php put in the following lines of code underneath “assign_to_config”:

    $assign_to_config['global_vars'] = array();
    $assign_to_config['global_vars']['foo'] = 'bar';

    You’ll now be able to access these variables as {foo}. Makes sense?

  • #3 / Jan 20, 2011 5:42am

    Mark Croxton

    319 posts

    Yes, thank you!

  • #4 / Jan 20, 2011 5:47am

    Ingmar

    29245 posts

    Excellent 😊 please post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases