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.

two global variable questions

January 20, 2011 10:57pm

Subscribe [3]
  • #1 / Jan 20, 2011 10:57pm

    Eric Snyder

    202 posts

    1) I cannot get global variables to work in a conditional:

    {if phone_800_number}
    
    {phone_800_number}
    
    {/if}

    If the above is a global variable then it does not output the value that is in the database. It does work if the above field is a snippet.

    2) If I use a global variable so that customer can put in information like local number and 800 number and they do not have an 800 number then you either have to delete the 800 number global variable or put a blank in the area for the value for the 800 number.

    In either case I either have to get the customer to remember to add the space (a lousy workaround) or delete the field (a more lousy workaround). If they delete the field then let’s say they add an 800 number to their business later. Then they need to add the 800 number global variable with the exact tag value so that the template that uses it will find the value.

    Am I missing something here? Why can’t a global variable or snippet be blank?

  • #2 / Jan 21, 2011 12:13am

    Cheif

    626 posts

    I’m not really getting your prose but are you looking to have the user fill in a entry with 2 phone numbers (normal + 800)and test to see if they’ve entered an 800 yes ?

    If they dont fill out 800 field then you can test to see if it’s empty and not show it or if is valid then show it.

    As i said, dont really get your premise and it’s a bit early to say global_var,snippets etc can be of benefit.

  • #3 / Jan 21, 2011 8:39am

    Eric Snyder

    202 posts

    That is exactly what I am doing and using a global variable as a conditional is not working but using a snippet does.

  • #4 / Jan 21, 2011 5:11pm

    Sue Crocker

    26054 posts

    Hi, Eric. Global variables are just plain text replacements. You’d need to use a snippet for this kind of functionality.

    Does that help?

  • #5 / Jan 21, 2011 5:43pm

    Eric Snyder

    202 posts

    Thanks Sue…
    What about #2 in the original post? If the snippet does not have a value then EE will not insert it in the database. In the case of a company telephone number some have one and some have two that they want to publish (local and toll free). If they don’t have some kind of value in the snippet then EE will not take it. This means that when they delete the snippet that holds the toll free number then they have to contact me later to set it back up if they get one. Is there a setting or something that I can use to get around this?

    So possibly a different question…how do people set up a customer with fields that they can fill in themselves that can be blank? A channel with one entry?

    What is the possible harm of allowing someone to submit an empty snippet or global variable? Is it a security risk?

  • #6 / Jan 23, 2011 2:13pm

    Greg Salt

    3988 posts

    Hi Eric,

    I’m afraid that I’m not really following you here but it does sound as if this type of content should be in a channel entry. Without visibility of your site setup and the access your client has its difficult to provide definitive advice but it may be that an addon like Low Variables would be helpful to you.

    Cheers

    Greg

  • #7 / Jan 23, 2011 4:58pm

    Eric Snyder

    202 posts

    Yes. I purchased Low Variables and it works much better than the built in EE global variable doe for this. The key thing is that Low Variables does not require the variable to be saved with a value - it can be saved empty.

  • #8 / Jan 24, 2011 9:01am

    Sue Crocker

    26054 posts

    Glad Low Variables will be helpful. Sounds like you have a solution, so closing thread. Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases