Low Variables and Pixel and Tonics' Matrix – a match made in heaven

Low Variables is a flexible ExpressionEngine add on in which we use on a number of sites. Going forward the sites in which it's not utilised by us, will be in the minority. It's hugely useful and hugely powerful.

For a few months now it's been possible to integrate Low Variables into Pixel and Tonic add ons such Playa, Assets, the DiveBar and Matrix, which will be focused on here.Every website is different but on the home page on a lot of recent sites we have built have been very different, with a lot of unique content areas, video, images, slideshows and the like. This therefore is a perfect fit for Low Variables. It doesn’t seem right to have a whole channel with a solely used gallery for example.

So with LV and Matrix, it's a match made in heaven.This code gives an example of what you can do. Whilst the client is unlikely to remove the items within the Matrix, the conditionals make it more robust and for you to have a contingency plan. The row counts allow you to have code above and below your looped matrix's. The possibilities are endless and your sites can be bulletproof, as flexible as you want and easily updated by your clients. Wonderful? Yes.


{if lv_matrix_name!= ''}
{exp:low_variables:pair var="lv_matrix_name" limit="2"}
        {if row_count=="1"}
            <ul>
        {/if}
            <li>{lvmf_field}<span>{lvmf_field2}</span></li>
        {if row_count==total_rows}
            </ul>
        {/if}
    {/exp:low_variables:pair}
{if:else}
<p>no low matrix</p>
{/if}

Remember to turn on early parsing for your matrix field so the conditionals will work.