Skip to content

Instantly share code, notes, and snippets.

@ijy
Last active December 18, 2015 20:49
Show Gist options
  • Select an option

  • Save ijy/5842992 to your computer and use it in GitHub Desktop.

Select an option

Save ijy/5842992 to your computer and use it in GitHub Desktop.
Conditionally check whether a Matrix is empty when searching on a particular column. Can be used with a Playa relationship field.
@ijy
Copy link
Author

ijy commented Jun 22, 2013

You can use the search:col_name= parameter in combination with :total_rows:

Where 'parent' is the matrix field name and 'child' is the matrix column name.

Copy link

ghost commented Mar 26, 2014

Here's an example of how it might look using the :total_rows and search in an EE conditional

{if "{matrix_field:total_rows search:column_name=''search term here"}

    {matrix_field search:column_name=''search term here"}
        <p>{col_names} … etc.</p>
    {/matrix_field}

{if:else}

    {other_custom_field}

{/if}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment