Looping through multiple category variable types.
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
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.
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"}
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?