Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Simple Grid Within Bloqs Warning

Status Resolved
Add-on / Version Simple Grids & Tables 1.2.0
Severity
EE Version 5.3.0

Josh Brodleit

Nov 19, 2019

We are getting this warning when trying to iterate over an empty grid.  The php version is

Warning
Invalid argument supplied for foreach()

user/addons/simple_grids/ft.simple_grid.php, line 158

    Severity: E_WARNING

This is what the template code looks like.

{enhancement_benefit prefix="eb:"}
  <li>{eb:benefit}</li>
{/enhancement_benefit}

I tried different ways to wrap the loop in an if check like this but none work:

{if '{enhancement_benefit}' != ''} 
OR
{if enhancement_benefit != ''}
OR 
{if '{enhancement_benefit}'}
OR 
{if enhancement_benefit} 
  {enhancement_benefit prefix="eb:"}
    <li>{eb:benefit}</li>
  {/enhancement_benefit}
{/if}


The php version info:
PHP 7.3.11-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:23:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
  with Zend OPcache v7.3.11-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Thank you,
Sheldon

 

#1

BoldMinded (Brian)

Hey, Josh. Before line 158 of that file, add this to see if it fixes it.

if (!is_array($data) || empty($data)) {
            return $tagdataOutput;
        }
#2

Josh Brodleit

The fix was mostly good, but it stopped the display of any simple grid. I removed the is_array check and that fixed it.

This is what worked for us.

if (empty($data)) {
    return $tagdataOutput;
}
#3

BoldMinded (Brian)

What happens if you return $tagdata, instead of $tagdataOutput?

Login to reply