I'm trying to set up Flexiblock with PHPTemplate on 4.6.6. I've inserted the code given in the Flexi documentation into the template:

<?php $blocks = theme('flexiblock_blocks', 2); ?>
  <?php foreach ( $blocks as $block ) { ?>
    <h3><?php echo $block['subject'] ?></h3>
    <?php echo $block['content'] ?>
<?php } ?>

I get the following error message:
Invalid argument supplied for foreach() - /path/to/page.tpl.php - line 60.

The plain HTML works perfectly:
theme('flexiblock_html', 2)

Comments

robertgarrigos’s picture

You can suppress this error message by changing each foreach function from this:

foreach ( $blocks as $block )

to this:

foreach ( (array)$blocks as $block )

(http://www.php.net/manual/en/control-structures.foreach.php#43653)

Or you can change your ini setting for error_reporting to a lower level

robertgarrigos’s picture

Status: Active » Closed (fixed)

Also, look at this comment: http://drupal.org/requirements#comment-160035

I close this because in fact is not a bug within the module's code but within its example code (commented) to use in the templates, although it might be nice to have that example code fixed also.