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

Support archive

Parsing Low Variable grid set as a Fieldtype

Seb Neerman 6 Nov 2018 14:50 question, complete

I've created an LV group that manages external article contributors/authors. Each variable in the group consists of a single two column grid containing the contributor's {name} and {url}.

Each variable name and label in the group will change according to who the contributor/author is, eg: News Agency A {news_agency_a}, News Agency B {news_agency_b}.

I then used the variable group to create a single select fieldtype dropdown {contributor_lv} in the Publish Form.

How do I access the LV grid data in the channel's template?

I've tried all sorts of combinations, such as:


{contributor_lv}
{exp:low_variables:pair var="{var}" }
<a href="{url}">{name}</a>
{/exp:low_variables:pair}
{/contributor_lv}


and:


{exp:low_variables:pair var="{contributor_lv}" }
<a href="{url}"">{name} </a>
{/exp:low_variables:pair}


But I'm getting no where. The variables are not set to early parsing, nor are they hidden. What's the correct syntax to access the LV grid data passed through a Fieldtype?

Thanks!

Replies

  1. Low 6 Nov 2018 15:29

    Try this inside the channel:entries tag:

    {exp:low_variables:pair var="{contributor_lv}"} 
    <a href="{{contributor_lv}:url}">{{contributor_lv}:name}</a>
    {/exp:low_variables:pair}

    Low 6 Nov 2018 15:36

    To explain, a regular LV Grid should be parsed like this (as per Grid's template tags):

    {exp:low_variables:parse var="my_grid_var"} 
    {my_grid_var:column1}, {my_grid_var:column2}
    {/exp:low_variables:parse}


    Since the LV fieldtype returns the variable name and you need the name of the Grid var to output column data, the those variables become variable themselves...

  2. Seb Neerman 6 Nov 2018 16:34

    Superb.

    That worked a treat!

    :)