ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

No results variable for grid field

November 09, 2014 2:11pm

Subscribe [2]
  • #1 / Nov 09, 2014 2:11pm

    Hi,

    I really need to detect if there is result output from my grid tag with search parameter. I don’t see any variable no_results in the documentation for the grid field and total_rows will not work with my search parameter.

    Is there any solution for this?

  • #2 / Nov 11, 2014 12:54pm

    Giraffentoast

    150 posts

    The only way to do this would be inserting all rows into an php array, I think.
    Something like this:

    <?php
    
    $gridRows = array();
    
    ?>
    {grid}
        <?php
    
        $gridRows[] = '{grid:field}';
    
        ?>
    {/grid}
    <?php
    
    if (empty($gridRows))
        {
        // array is empty
        }
    else
        {
        // do something with the rows
        }
    
    ?>

    Untested, but this should work. Change “PHP Parsing Stage” of your template if it doesn’t.

    Hope the grid tag pair gets upgraded soon.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases