0

have this table that I want to display only if one parameter set in a matrix cell has a value of 1:

{exp:channel:entries channel="{canale_corrente}" limit="1" disable="member_data|pagination|categories"}         
                                {formati_prodotti}
                                    {if enable_shop_lnk == "1"}

                                    <div class="small-12 column">
                                        <div class="content-box">
                                            <h2>TITLE</h2>
                                            <p class="subhead">SUBTITLE</p>
                                            <table width="100%">
                                                <thead>
                                                    <tr>
                                                        <td>Formato</td>
                                                        <td>Shop</td>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>{codice_formato} - {nome_formato}</td>
                                                        <td><a href="#" class="tiny button radius">BUY</a></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    {/if}
                                {/formati_prodotti}
                            {/exp:channel:entries}

CAPTION:

{formati_prodotti} is a matrix field

enable_shop_lnk is a child field inside {formati_prodotti} that can be 0 or 1

the problem is that I can't find a way to hide the entire table when there's no records with enable_shop_lnk == 0

Also because the enable_shop_link is inside a matrix field I can check it only by wrapping it with the matrix field {formati_prodotti} and if there's more than one entry meeting the criteria I get more than one table!

Any idea!

2 Answers 2

1

You can wrap the whole {formati_prodotti} tag pair in this conditional:

{if '{formati_prodotti:total_rows search:enable_shop_lnk="1"}'}
    {formati_prodotti}
        ...
    {/formati_prodotti}
{/if}

See http://docs.pixelandtonic.com/matrix/templating/field.html#total-rows

1
0

try

{if "{enable_shop_lnk}" == "1"}

Regard's.

1
  • the conditional is working perfectly the real problem is that this field is a matrix child and I can check it only wrapping it inside the matrix tag so for example if there are 3 products i get 3 different tables! Mar 19, 2014 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.