GENESIS THEME Countable Errors Fix

Permalink
This error is being caused by a pagelist template.
If you look at:
packages > c5box_genesis > blocks > page_list > templates > c5box_plist_4col_carousel > view.php
you will find on line 16 this code...
<?php if (count($rows) > 0) { ?>
  <?php foreach (array_slice($rows, 1) as $row) { ?>
    <i class="fa fa-circle-thin" aria-hidden="true"></i>
  <?php }
        }
?>

Change it to this...
<?php 
  if (is_array($rows) ) { // add this line to fix Countable error
  if (count($rows) > 0) { ?>
    <?php foreach (array_slice($rows, 1) as $row) { ?>
    <i class="fa fa-circle-thin" aria-hidden="true"></i>
  <?php }
        }
        } // and this line also
?>

The same applies to this file...
packages > c5box_genesis > blocks > page_list > templates > c5box_plist_3col_carousel > view.php

ConcreteOwl
 
mnakalay replied on at Permalink Reply
mnakalay
To avoid the double if you can do
if (is_array($rows) && count($rows) > 0) {

if the first part of the if check fails it won't check the second one so there will be no error
JohntheFish replied on at Permalink Reply
JohntheFish
My personal preference (and it is only a matter of preference, all the above are just as good)
if (!empty($rows) && is_array($rows)) {


As $rows for a page list when not empty will be an array with >=1 item, that can be shortened to
if (!empty($rows)) {
ConcreteOwl replied on at Permalink Best Answer Reply
ConcreteOwl
Yes there are several ways to tackle this problem.
I prefer my method since the code does not belong to me and it would be very easy to return the file to its former state by deleting the two commented lines.