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

Support archive

Variable not working inside exp:weblog:entries tag

Erik Reagan 5 Jul 2010 15:32 question, complete

Low

I think this is possible but I might be doing it incorrectly.

I'd like my client to manage a set of Entries from which they will display one on their homepage at random. I have a Select Entries variable setup with multi-select as an option using drag/drop & pipe delimited. It is also set to early parsing.

I'm trying to use it like this:

{exp:weblog:entries
weblog="products"
disable="categories|category_fields|member_data|pagination|trackbacks"
status="open|Featured"
limit="1"
search:product_availability="{country_seg}"
dynamic="off"
entry_id="{products_{country_seg}_featured}"
orderby="random"
}
{title}
{/exp:weblog:entries


When I view the query in EE it shows that the variable isn't getting parsed.


...
AND t.entry_id = '{products_us_featured}'
...


However, if I just place the variable anywhere outside of the exp:weblog:entries tag parameter then it displays the entry IDs pipe delimited as expected.

Any thoughts? Thanks!

--------------
EE 1.6.9 20100430
Low Variables 1.2.4
PHP 5.2.12

Replies

  1. Low 5 Jul 2010 15:47

    Hey Erik,

    The answer is: Parse Order! And to be precise, it's the order in which the Early Parsed global variables are parsed. These variables include path.php vars and LV vars with Early Parsing enabled.

    As you may know, there's an array that stores all these variables. The order in which they are present in that array matters in this case. Apparently, {products_us_featured} is parsed before {country_seg}.

    Is {country_seg} a path.php variable or is it set by another extension? If it's set by a custom extension, you could change its priority and see what happens.

    You could also try the following. Open ext.low_variables.php en look for line #241. There you can see this code:

    //$IN->global_vars = array_merge($IN->global_vars, $early);
    $IN->global_vars = array_merge($early, $IN->global_vars);


    Uncomment the first line and comment out the second. That way existing global vars (like path.php vars) are kept 'on top' of the global vars array and should be parsed before LV vars with early parsing.

    Hope that helps.

  2. Erik Reagan 5 Jul 2010 16:17

    Thanks for the quick reply :)

    I knew it was parsing order I just didn't know where to get started. I tried reversing the commented lines around #241 and there was no change in behavior.

    Is {country_seg} a path.php variable or is it set by another extension?

    It's set in path.php. Sorry I didn't clarify that earlier.

    I also turned early parsing off for this variable and experienced the same thing.

    It should be possible to use LV for a weblog:entries parameter shouldn't it? Could I have missed something else along the way?

    Thanks :)

  3. Low 5 Jul 2010 16:28

    It should be possible to use LV for a weblog:entries parameter shouldn't it?


    It definitely should. All vars with early parsing enabled can be used as input for template tag parameters.

    If you turn on template debugging, take a look at the 'Global Path.php Variables (Keys)' and 'Global Path.php Variables (Values)' lines, somewhere at the top of the list. There you'll see pipe-separated lists of all the vars in $IN->global_vars which will be parsed from left to right. Take a look at the difference in that order between commenting out the first and the second line like you did.

    Can you see a difference, there?

  4. Erik Reagan 5 Jul 2010 18:58

    So, this was driving me crazy so I left it for a few hours and came back to it with a fresh mind. I "un-did" all my attempts and re-tried it.

    Everything works as expected now. I probably had a lame typo somewhere along the way. I change the ext file back to "out of the box" and all is well.

    Thanks for your time Low!

  5. Low 5 Jul 2010 19:03

    Great, glad you got it working!