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

Support archive

Early parsed variables, channel entries, and channel parameters

ben.parizek 13 Nov 2011 02:46 question, complete

I'm trying to better understand what the parse order is for early parsed variables. I have an early parsed Low Variable that includes a channel entries tag. In the tag I've created a pipe delimited list of entry IDs and trying to pass the value to the channel entries tag on one of my pages in order to limit what the tag outputs. This works fine if I pass the Low Variable to an embed and the embed variable to the channel tag, but it doesn't work if I just pass it directly to the channel tag. What is being processed out of order? Aren't snippets, and Low Variables supposed to process early enough to be used as variables?

For reference, my Low Variable:

{exp:channel:entries channel="CHANNEL_NAME" author_id="CURRENT_USER"}{exp:playa:parents channel='CHANNEL_2_NAME' backspace='1'}{entry_id}|{/exp:playa:parents}{/exp:channel:entries}


And my Channel Tag in the template:
 
{exp:channel:entries channel="CHANNEL_NAME" orderby="title" sort="asc" entry_id="{LOW_VARIABLE}"}
{entry_id}::<strong>{title}:</strong><br />
{exp:playa:parents channel="CHANNEL_2_NAME"}
{title}<br />
{/exp:playa:parents}
{/exp:channel:entries}


The above code does not work. I even tried removing the playa tags and everything in between and just hard coding my pipe delimited list. The following embed does work:

{embed="template_group/.template" low_variable_name="{LOW_VARIABLE}"}{/exp:low_variables:parse}


I'm just wondering what the parse order is for channel tags I guess as I seem to try this a lot and fail. Are there any EE tags that can be parsed at this stage and be passed directly to a channel entries tag? Or will I always have to use an embed to do something like this? (I'm extremely resistant to embeds =)

No hurry on this one.

Thanks!

Replies

  1. Low 14 Nov 2011 11:51

    Hi Ben,

    Here's the rub: Snippets and (early parsed) Low Variables are simply string replacements. Their contents are NOT parsed before they hit the template.

    The contents are parsed by the template parser. In your first example, it would mean you're putting the contents of the LV inside the parameter value of a channel:entries tag, which won't work.

    In your second example, the contents of the LV is put inside an embed, which is parsed at the very end of the parse order, as a separate template, which is why id does work.

    If in doubt, try this: take the contents of the LV and put it in your template itself, where the {LOW_VARIABLE} would be. If that code works, then it's suitable for a snippet/early parsed LV. If it doesn't, you might have to resort to an embed.

    Hope that sheds some light.

  2. ben.parizek 15 Nov 2011 17:18

    Thanks Low. That helps a lot.