brockpetrie/dynamictextgroup — pull request #9 by bauhouse (2012-02-01 00:52:22+00:00)
Title: Development

I tried setting up the Dynamic Text Group (DTG) extension as a field in a subsection. So far, I've found that Subsection Manager and DTG works quite well. But the problem that I have encountered involves having an empty Dynamic Text Group field in an entry. This appears to break the XML and no further entries will be output.

Invalid argument supplied for foreach()

So, it looks like the solution to [the problem](http://php.syntaxerrors.info/index.php?title=Invalid_argument_supplied_for_foreach) is fairly simple.

Test whether the `$data` variable is an array:

if(is_array($data)) {
foreach ($data as &$row) { if (!is_array($row)) $row = array($row); }
}

Problem solved. (See discussion on the [Symphony CMS forum](http://symphony-cms.com/discuss/thread/70781/3/#position-45).)