1

I've got a variable set up as a 2-col Matrix for easy editing of days/hours (for being open). I'm wanting to nest this in another variable, that contains the mark-up for this snippet (so-to-speak). I have early parse enabled the Matrix var type but within the {lv_footer}, it just returns the code as a string from the "nested" var {lv_hours}. Anyway I can have that parse before the {lv_footer} is parsed?

Here is code in the lv_footer (saved as file):

<div class="hours">
    <h3>Hours:</h3>
    <dl class="hours">
    {exp:low_variables:pair var="lv_hours"}
        <dt>{day}</dt>
        <dd>{hours}</dd>
    {/exp:low_variables:pair}
    </dl>
</div>

2 Answers 2

2

I'm pretty sure this has to do with the way Low Variables parses nested variables. You may need to add both of these variables to the same group and in the right order for them to parse correctly: {lv_footer} should be above {lv_hours} in the same group

Nesting

[cue Inception music] So, there are three stages at which a Low Variable can be parsed:

  1. As early parsed global variables using the variable syntax (stage 1)
  2. As tags, single or pair, using the tag syntax (stage 5)
  3. As late parsed global variables (the default) using the variable syntax (stage 9).

Looking at these stages, you can always nest variables upwards: 2 in 1, 3 in 1, and 3 in 2. As noted before, you can also nest 1 in 1, but only if they are in the same group and in the right order. Theoretically, you can nest 2 in 2, but that might cause your brain to melt. Nesting 3 in 3 won’t necessarily break things, but it can lead to unexpected results. Nesting 1 in 2, 1 in 3, or 2 in 3 will never work.

More on the parse order

2

If you look at the Nesting quote Siebird posted, you'll also need to know what the different stages (1, 5 and 9) mean.

Stage 1 is for early parsed global variables: Low Variables with early parsing enabled and in variable syntax: {lv_my_variable}

Stage 5 is for tags: Low Variables using the tag syntax: {exp:low_variables:single var="lv_my_variable"} Note: Early Parsing has no effect when using the tag syntax!

Stage 9 is for late parsed global variables: Low Variables with early parsing disabled and in variable syntax: {lv_my_variable}

This means, for your example, that you have 2 vars that are nested. One of them, lv_hours, needs the tag syntax, and therefore is parsed at stage 5. So if you want to nest it inside lv_footer, you need to parse that one in stage 1: make sure you use variable syntax and that early parsing is enabled.

2
  • Is it possible to use variable syntax with a Matrix variable type? I tried essentially replacing the tag syntax and just use the var name (ie. {lv_hours}{/lv_hours}) without success. How can I get that var to parse in stage 1? And do they need to be in the same group? (thanks for the help - first time using Low Variables)
    – Ryan Shrum
    Commented May 29, 2013 at 14:55
  • No, global variables do not support the variable pair syntax. Matrix vars can only be parsed using the tag syntax. But as long as the lv_footer is parsed early, and it contains the matrix var tag, it should work.
    – Low
    Commented May 29, 2013 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.