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

Support archive

Looping through multiple category variable types.

shandy 22 Mar 2010 17:48 question, complete

I'm trying to loop through a multiple category variable type. When I select 3 categories the following code is output using:

{exp:low_variables:parse var="active_upgrades" multiple="yes"}
Number {count} of {total_results}: {active_upgrades}

{/exp:low_variables:parse}

Outputs:

Number 1 of 3: 15|20|8

Number 2 of 3: 15|20|8

Number 3 of 3: 15|20|8

When I need (and expected to get?)

Number 1 of 3: 15

Number 2 of 3: 20

Number 3 of 3: 8

Thanks for your help.

Replies

  1. Low 22 Mar 2010 17:54

    Hi Shandy,

    I take it you have Early Parsing enabled for active_upgrades? If you're not using the variable somewhere else, you might want to turn it off. If you are using it elsewhere and need Early Parsing to be on, replace the {active_upgrades} tag inside the {exp:low_variables:parse} tag pair with {value}. That way it doesn't get parsed before the regular template parser gets to it.

    shandy 23 Mar 2010 17:40

    Hello again. This is related to the last question I had. I'm trying to use {value} as an ff matrix search parameter within a {exp:low_variables:parse} loop, something like this:

    {exp:low_variables:parse var="config_categories" multiple="yes"}
    {upgrades search:upgrade_type="{value}"}

    {upgrade}


    {/upgrades}
    {/exp:low_variables:parse}

    If I replace {value} with an actual category id eg. 15 it works fine but using {value} doesn't work at all?

    Thanks.

  2. Low 23 Mar 2010 18:14

    Hi Shandy,

    If you're going to nest tags like that, I think you might need to turn parsing to inward, like this:

    {exp:low_variables:parse var="config_categories" multiple="yes" parse="inward"}

    shandy 23 Mar 2010 19:57

    I tried that but no joy. Definitely seems to be to do with the parsing order as I can 'print' out the correct {value} elsewhere in the tag pair it's just not being recognised when I try to use it as a search parameter...

  3. Low 23 Mar 2010 21:07

    Parsing order gets confusing inside a {exp:weblog:entries} tag pair.

    Custom fields within the weblog entries tag pair are parsed before other tags are parsed. This makes sense, because that's why things like this work:

    {exp:weblog:entries weblog="blog"}
    {exp:textile}{my_body_text}{/exp:textile}
    {/exp:weblog:entries}


    First the field {my_body_text} is parsed, then the Textile plugin kicks in and formats the output. This means that your FF Matrix field (upgrades) will be parsed before the {exp:low_variables:parse} tag will be processed, thus keeping the literal string '{value}' as a parameter. Only after all the custom fields are parsed, then the
    {exp:low_variables:parse} tag starts to do its thing.

    The only way to work around this, is to put the {exp:low_variables:parse var="config_categories" multiple="yes" parse="inward"} tag outside the {exp:weblog:entries} tag. However, I do not recommend this, as this will cause the weblog:entries tag to loop. If you do use this approach, keep a keen eye on your performance!

    Make sense?

    shandy 23 Mar 2010 21:20

    Yes, that makes sense. I got around it by embedding the ffmatrix field and passing {value} as an embed variable although I guess I'm still looping weblogs doing it this way. Thanks for your input anyway...