Issue with using a Structure global variable tag inside a Low Variable tag as the value for the limit="" parameter
I have a Structure site that requires the client to have more granular control over pagination limit, etc. So I'm trying to use early-parsed Low Variables for these settings and it works great except when I try to make the variable even more dynamic...
Here's the set-up:
* I have a listing channel named "collections"
* On a certain structure page, the {structure:child_listing:short_name} Structure global variable tag will output "collections" as the channel short name
* So in my template, I am trying to do something like this...
{exp:channel:entries
channel="{structure:child_listing:short_name}"
limit="{var_channel_limit_{structure:child_listing:short_name}}"
}
the above outputs this...
{exp:channel:entries
channel="collections"
limit="{var_channel_limit_collections}"
}
* So I have a Low Variable called "var_channel_limit_collections" that is set to parse early
* To make it dynamic based on the active Structure page, I am using {var_channel_limit_{structure:child_listing:short_name}} tag... which outputs perfectly when not used as a value for a channel parameter.
* But as a channel parameter, it outputs as limit="{var_channel_limit_collections}"
I assume this is expected behavior but I wanted to bring it up in case there was a solution I was missing.
Any insights would be appreciated.
Replies
Low 5 Jun 2012 10:41
Hi Mark,
All Low Variables, including the early parsed ones, will be replaced with their values at the very end of the parse order (because LV uses the native global_variables to store their data). The ones with Early Parsing enabled, will be replaced at the very beginning, if they're there.
By the looks of it, early parsed LVs will be parsed first, after which the {structure:child_listing:short_name} will be parsed. This isn't something I can control.
The order in which your var is parsed will be this:
1. Beginning of template:
{var_channel_limit_{structure:child_listing:short_name}}
2. Early parsed LV can't find it, so it remains:
{var_channel_limit_{structure:child_listing:short_name}}
3. Stucture var is parsed:
{var_channel_limit_collections}
4. Tags and plugins are parsed, leaving the above var unparsed:
{var_channel_limit_collections}
5. Late parsed vars are parsed, replacing the var with the actually value:
5
The whole point is that both the structure-var and LV are early parsed vars, but I cannot control which of those is parsed first. If you look at this blog post: http://gotolow.com/blog/parse-order-a... ...both vars are parsed at stage #1, which makes it harder to set their order.
Mark Terpstra 5 Jun 2012 15:48
That all makes perfect sense and I was guessing it was a parse order issue outside your control. Thanks for your time, Low.