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

Support archive

Is there a way to display all the variables in a group?

Jonathan Longnecker 14 Dec 2015 14:28 question, complete

I'm using Low Variables to show what's included on a product. On our listing page we show little icons based on what's included. That works great, but what I'm trying to do is create a legend elsewhere on the page to tell the user what the icons mean.

I had hardcoded the legend items like so:

 
{exp:low_variables:pair var="lv_included_hvac" multiple="yes"}
{lv_short_desc}{/exp:low_variables:pair}


The legend was supposed to be static and consistent, but now the client is asking if it can be dynamic based on the variables he creates.

I've looked all over the documentation, but haven't found if there's a way to do something like the above with a group parameter to spit out all the variables in that group. Is it possible?

If so, something like this:

 
{exp:low_variables:pair group_id="9" multiple="yes"}
{lv_short_desc}{/exp:low_variables:pair}


thanks,

Jonathan

Replies

  1. Low 14 Dec 2015 14:51

    No, there's currently no out-of-the-box method of outputting all vars in a group like that.

    You can consider using a single Grid or Matrix variable instead, or use the Query module to generate a list of variable names in a given group.

  2. Jonathan Longnecker 14 Dec 2015 15:05

    Darn it! I was hoping it would be easy :) What about looping through all the entries in a channel and showing which variables have been selected (without duplicating)?

    If not, any chance you could point me the right direction for that SQL query?

    thanks!

    Jonathan

  3. Low 14 Dec 2015 15:27

    No, using the channel:entries tag like that would be even more cumbersome.

    Use something like this:

    {exp:query sql="SELECT variable_name FROM exp_global_variables ee INNER JOIN exp_low_variables low ON ee.variable_id = low.variable_id WHERE group_id = 9 ORDER BY variable_order ASC"} 
    {exp:low_variables:parse var="{variable_name}"}
    {/exp:query}

  4. Jonathan Longnecker 14 Dec 2015 17:38

    That worked perfectly, just had to swap out the :parse for :pair since my variable was a Matrix field.

    thanks, sir!

    Jonathan