All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Use template tag and language variable

Fernstrg 10 Jul 2011 19:18 question, complete

Hi,

I made a multi-language site using Structure, so there's no global language variable. I pull the current language from a URL segment and use a "preload_replace" to insert it into the various tags in my template.

This apparently means I cannot use the advanced features of Low Variable's {exp:low_variables:parse} tag, like for example the format parameter or the site prefix (which would save me recreating the fields in all three sites in this MSM installation).

Is there a way to use "preload_replace" AND the {exp:low_variables:parse} tag?

Replies

  1. Low 11 Jul 2011 07:23

    Hi!

    I'm not quite sure what you're trying to do. Do you have a code example? And I'm sure you've seen my parse order cheat sheet, right?

  2. Fernstrg 14 Jul 2011 11:19

    I want to for example display my variable with <br/> formatting.

  3. Low 14 Jul 2011 11:25

    Okay, so then you'd use the {exp:low_variables:parse var="my_textarea_var" format="br"} right?

    How does the preload_replace variable fit into this?

  4. Fernstrg 19 Jul 2011 15:52

    It's {exp:low_variables:parse var="my_textarea_var_{my_language_switch}" format="br"} and the "{my_language_switch}" is a preload replace variable.

  5. Low 19 Jul 2011 21:00

    Okay, and how are you setting the preload replace variable?

  6. Fernstrg 20 Jul 2011 09:13

    It grabs the language snippet from a URL segment.
    {preload_replace:lang_switch="{if segment_1 == 'de' || segment_1 == 'en'}{segment_1}{if:else}nl{/if}"}

  7. Low 20 Jul 2011 13:33

    Aye, there's the rub. You're using an advanced conditional there. Parse order will mess this up.

    Try this instead:

    {if segment_1 == 'de'} 
    {preload_replace:lang_switch="de"}
    {/if}
    {if segment_1 == 'en'}
    {preload_replace:lang_switch="en"}
    {/if}
    {preload_replace:lang_switch="nl"}


    It's more verbose, but this way, the {lang_switch} variable will actually contain either 'de', 'en' or 'nl'. If you use your method, the variable will contain the actual conditional instead of the resolved value.

  8. Fernstrg 31 Jul 2011 16:12

    That works, thank you!

  9. Low 1 Aug 2011 10:34

    You're welcome!