Low variable inside channel entries tag
I have a variable name "breadcrumb" containing this:
{exp:taxonomy:breadcrumbs tree_id="2" delimiter=">" use_custom_url="yes" entry_id="{entry_id}"}
Now i would like to do this:
{exp:channel:entries channel="general" limit="1"}
{exp:low_variables:parse var="breadcrumb"}
{/exp:channel:entries}
The entry_id is not pushed to low variables, with or without early parsing.
How can i fix this?
Replies
Low 18 Apr 2012 14:39
Ah, parse order strikes again. First, take a look at the Parse Order pdf. Then consider this: say you have a variable called {lv_myvar}...
* With early parsing enabled, {lv_myvar} is parsed at stage 1.
* {exp:low_variables:parse var="lv_myvar"} is parsed at stage 5, regardless of early/late parsing
* With early parsing disabled, {lv_myvar} is parsed at stage 9.
Then, consider how exp-tags are parsed at stage 5. Take a look at my Parse Order Pro slides, starting from slide #88 (Tags).
Taking that order into consideration, in your example, the channel:entries tag is parsed first, including the {entry_id} variable. Then the low_variables:parse tag is parsed, resulting in the taxonomy:breadcrumbs tag, which will be parsed consecutively. But since the channel:entries tag has already been, the {entry_id} you want cannot be replaced anymore.
So, to get around it, instead of using the low_variables:parse tag, use the simple variable syntax and make sure early parsing is enabled. So:
In this case, {breadcrumb} will be parsed at stage 1, making sure the taxonomy:breadcrumbs tag (including the {entry_id} variable} is present in the template when the channel:entries tag is parsed.
Get it? :)
Frans Cooijmans 18 Apr 2012 14:49
Got it, using simple syntax + parse early now.
Didn't know there was a difference, maybe add it to your docs? or am i just being stupid :).
Low 18 Apr 2012 14:51
Cool.
Guess it's kind of implicit, but I agree. Some sort of overview in the docs might be quite useful.