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

Support archive

Generate all variables contained in an LV group

Seb Neerman 26 Feb 2013 10:42 question, complete

I want to generate all variables that are contained in an LV group. The aim is to then use them to populate the option values of a select dropdown for use in (Solspace's) Super Search. The variables also all follow the same naming convention article_type_name.

I don't want to hardcode them, because they may be added, removed and edited by the client. The group of variables are also used as dropdown custom field group in the site's publish forms.

How can I go about it?

Replies

  1. Low 26 Feb 2013 10:49

    You could use the Query module:

    {exp:query sql="SELECT ee.variable_name, low.variable_label 
    FROM exp_global_variables ee, exp_low_variables low
    WHERE ee.variable_id = low.variable_id
    AND low.group_id = 'X'
    ORDER BY low.variable_order ASC"}
    <option value="{variable_name}">{variable_label}</option>
    {/exp:query}


    ...where X is the variable group ID.

  2. Seb Neerman 26 Feb 2013 11:55

    Thanks Low. I'll give that a go.

    On a different note, could you kindly remove this post as 1Password and Get Satisfaction's login modal have decided to replace my post's title with my login address.

  3. Low 26 Feb 2013 11:57

    I believe you should be able to edit the post. If you can, please do, so I can keep the thread for future reference.

  4. Seb Neerman 26 Feb 2013 12:28

    No, it's not possible to edit it. I've sent GS support a mail though.

    Back on topic... I've tried the query but I'm getting nothing. I've double checked the low.group_id (3). I've tried moving the query outside the super:search tag. And template debugging doesn't reveal anything untoward.

  5. Low 26 Feb 2013 12:31

    Just tested it; the query should produce results. Are you sure the Query module is installed?

  6. Seb Neerman 26 Feb 2013 13:06

    Please ignore my madness. It's working beautifully :) You'r a star, thanks.

    And GS have changed this post's title.