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

Support archive

Low Variable Inside Channel Entries Tag

kgrote 4 Jul 2012 20:03 question, complete

Here's my code:


{exp:channel:entries channel="mychannel" dynamic="no"}
{my_low_variable_{segment_2}}
{/exp:channel:entries}


The low variable is set to early parsing, but unfortunately the channel fields inside it are not being parsed and I don't get why. As I understand it, the parse order I have going here is:

1. parse segment variable & low variable
2. parse channel module tag

And in my mind that should work, but I must be missing something! I know the low variable is parsing correctly because it's returning the field tags, it's just that the content isn't being parsed by the channel entries tag.

Replies

  1. Low 4 Jul 2012 20:08

    Step 1 is almost right. Snippets (and early parsed LVs) are parsed first, then segment variables, so you're example won't work, I'm afraid...

  2. kgrote 4 Jul 2012 20:11

    Aww, man!

    I'm confused because the contents of the low variable is being returned, which would imply that the segment variable is parsing correctly, right?

  3. Low 4 Jul 2012 20:20

    So, Low Variables are stored in the native global_variables table, which is used for the late parsed vars. This means *all* LVs will be parsed at the end of the parse order.

    LVs with early parsing enabled will be added to the Snippets array, and therefore parsed at the beginning of the parse order, before the segment vars.

    If somewhere along the line segment vars are parsed again, which could well be the case in a channel:entries tag, then the LV in your example will not be recognized at the beginning, but it will be parsed at the end, like all LVs are.

    Does that make sense?

  4. kgrote 4 Jul 2012 20:25

    Yes, that makes sense. I didn't know segment variables could be parsed again after the fact.

    OK then, in a similar vein, if I want a LV containing channel fields to be parsed correctly, I'd need to do this, right?:


    {exp:channel:entries channel="mychannel"}
    {exp:low_variables:single var="my_variable"}
    {/exp:channel:entries}


    And obviously early parsing would be disabled, though I imagine the {exp:low_variables:single} tag cancels that out anyway.

  5. kgrote 4 Jul 2012 20:28

    Er, sorry, that wasn't the full story. I wanted to pass an embed variable to the LV, so I can't enable early parsing:


    {exp:channel:entries channel="mychannel"}
    {exp:low_variables:single var="my_variable_{embed:unique_id}"}
    {/exp:channel:entries}


    Probably not possible either, eh?

  6. Low 4 Jul 2012 20:31

    No, that won't work because the channel:entries tag will be parsed before the low_variables:single tag.

    But what if you add the whole {exp:channel:entries} tag to the LV? You can then use LV 2.3.0's preparse parameters to pass vars to that var's content.

  7. kgrote 4 Jul 2012 20:39

    Unfortunately that won't work because the fields inside the LV are shared between a channel entries tag and a super search results tag, so it needs to be content only so it can be swapped around.

    Oh well, I was trying to avoid using conditionals but I guess even low variables can't work miracles :D

    I don't see anything about preparse parameters in the docs, where would I go to learn about that?

    Thanks for the quick response!

  8. Low 4 Jul 2012 20:46

    Preparse vars are part of the Textarea var type: http://gotolow.com/addons/low-variabl...

    You could, in theory, use something like this:

    {exp:low_variables:single var="my_var" preparse:tag="channel:entries"}


    or

    {exp:low_variables:single var="my_var" preparse:tag="super_search:results"}


    And in your var:

    {exp:{tag}} 
    ...
    {/exp:{tag}}

  9. kgrote 4 Jul 2012 22:33

    Hmm, I think it's too late in the day for my brain to be able to handle that, but I'll look into it, thanks :)