0

I am having a Matrix fieldtype with two cells: text and Playa. The text field serves as the title for different rows. It's setup like this in my code:

{my_matrix_field}
    <div class="products">

        <h2>{cell_1}</h2>

        <ul class="noGrid">
            {cell_2}{stash:embed name="snippets:productdiv" process="start"}{/cell_2}
        </ul>

    </div>
{/my_matrix_field}

I would now conditionally show or hide {cell_1} based on the results of cell_2. If for example all entries are set to closed I want the cell_1 to not display anymore.

I have tried the syntax from this post, but without any luck.

2 Answers 2

1

Well, it's not super-simple. At least the solution that I came up with. It also might end up costing performance a bit.

So, first thing first: We need to see if some entries are selected, that are not closed. To do that, we could use {cell_2 var_prefix="playa" status="not closed"}{playa:entry_id}{/cell_2}. Now, you can try using that in an if statement such as:

{if '{cell_2 var_prefix="playa" status="not closed"}{playa:entry_id}{/cell_2}'} {cell_1} {/if}

0
1

You could try

{if cell_2}<h1>{cell_1}</h1>{/if}

This simple conditional checks for the presence of info in cell_2 and outputs the h1 if populated otherwise it will output nothing.

1
  • It's not working. :(
    – Marc
    Dec 28, 2013 at 20:41

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.