Use template tag and language variable
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
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?
Fernstrg 14 Jul 2011 11:19
I want to for example display my variable with
<br/>
formatting.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?
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.
Low 19 Jul 2011 21:00
Okay, and how are you setting the preload replace variable?
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}"}
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:
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.
Fernstrg 31 Jul 2011 16:12
That works, thank you!
Low 1 Aug 2011 10:34
You're welcome!