Be sure to checkout our newest add-on, Speedy — Advanced Caching for ExpressionEngine.

Compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field (it's in the works).

Ticket: Simple Grid Within Bloqs Warning

Status Client Wait
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)

Nov 21, 2019

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

Nov 21, 2019

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)

Nov 21, 2019

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

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.