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.

Global Variable in Conditional Not Working

May 12, 2014 9:33pm

Subscribe [2]
  • #1 / May 12, 2014 9:33pm

    motorstormer

    17 posts

    I’ve created a global variable in Expression Engine to be able to switch to a testing mode for a site I am testing. The global variable is called ‘test-mode’ and the content is the word ‘true’.  But it is not working in an if statement.

    {if test-mode == "true"}hello world{/if}

    EE doesn’t show the “hello world” text. If I do this:

    {test-mode}

    It shows “true”. I can’t figure out why it’s not working…

  • #2 / May 13, 2014 7:49am

    Boyink!

    5011 posts

    Try:

    {if test-mode==true}

    This worked on my local install.

    But do note that if you are trying to use this around other EE code you’ll likely have mixed results. EE’s parse order comes into play here, and global variables are evaluated late in the process.

  • #3 / May 13, 2014 8:31am

    motorstormer

    17 posts

    That worked!  Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases