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 variables inside conditionals

August 03, 2007 5:32am

Subscribe [3]
  • #1 / Aug 03, 2007 5:32am

    sallyoz

    5 posts

    I want to use two global variables {trip_time} and {luggage_limit} inside an if statement. The aim is if the weblog field ‘passes_triptime’ contains certain text - eg “1 Day” display the luggage limit else leave it out.  I use global variables for my different language modules.

    It works okay if I put in the text

    {if "{passes_triptime}” <> “1 Day”}
    {passes_luggage_limit}
    {/if}

    but when I use the global variable {trip_time} with a value of “1 Day” it does not work.
    {if "{passes_triptime}” <> {trip_time}}
    {passes_luggage_limit}
    {/if}

    It prints out }15Kg luggage limit instead of leaving blank for 1 Day trips.  I have tried using quotes around global variables but still no good.

    I am using latest version of EE 1.6.0.

    Thanks

  • #2 / Aug 03, 2007 12:55pm

    Derek Jones

    7561 posts

    What is the source of the global variables?  There are different types (path.php, dynamically assigned, template globals, etc.) that are parsed at different times for different uses.  Also, please read the KB article Troubleshooting Conditionals, as you are using incorrect syntax (variables should not be braced nor quoted).

  • #3 / Aug 03, 2007 1:25pm

    Sue Crocker

    26054 posts

    sallyoz, it might be a parsing issue.

    Path.php globals

    Global path.php variables are parsed earlier. See if setting this up helps. It did for me.

  • #4 / Aug 05, 2007 4:23am

    sallyoz

    5 posts

    Thanks - the path.php global templates worked but are not feasible in my application which is a bit outside the norm.

    We use template global variables to switch between English, French, Japanese and Korean languages but use only one weblog for each page not four. We have modified mod.weblog.php to do this. 

    I’m not sure if you are interested but if so go to http://www.ozexperience.com/index.php/travel/passes_national/fish_hook_pass_melbourne_to_alice_springs/  You will see the English version but if you click French on the menu bar it will switch to the same page in French.

    This works really well for us and is very easy to maintain - we have template global variables and weblogs for each language with the same name but either _fr,_jp or _kr for the extension.  We therefore only need to upkeep one template for each page. ie {trip_time} will automatically deliver {trip_time_fr}, {trip_time_kr} or {trip_time_jp} depending on language chosen. 

    I will use some if: ifelseif: like statements for this particular problem.  Everywhere else the template globals are terrific.

    Thanks again

  • #5 / Aug 05, 2007 8:19am

    Derek Jones

    7561 posts

    Sallyoz there are two articles in the wiki regarding running multilingual sites that you may wish to read.  Neither of them require any modification of the back end, as that can make it difficult to support the installation, and requires more time and effort to maintain your changes across updates.

  • #6 / Aug 05, 2007 9:40am

    sallyoz

    5 posts

    Hi Derek

    Thanks for the info.  We did look at this but our client required separate logins for each translator to have access to only their weblogs.  Our solution works well for this.  From what I saw the WIKI solution uses one weblog for all languages so I could not see how to invoke the separate secure logins.

    Our changes are not too major and so far we have had no trouble upgrading.

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

ExpressionEngine News!

#eecms, #events, #releases