function tablefield_hide_rows in TableField 7.2
Same name and namespace in other branches
- 7.3 tablefield.module \tablefield_hide_rows()
Hide all empty rows.
Parameters
array $tabledata: The rationalized tablefield.
bool $ignore_head: Whether ignoring header or not.
2 calls to tablefield_hide_rows()
- tablefield_field_formatter_view in ./
tablefield.module - Implements hook_field_formatter_view().
- tablefield_hide_cols in ./
tablefield.module - Hide all empty columns.
File
- ./
tablefield.module, line 1539 - Provides a set of fields that can be used to store tabular data with a node.
Code
function tablefield_hide_rows($tabledata, $ignore_head = FALSE) {
foreach ($tabledata as $key => $value) {
// Removes the weight key.
unset($value['weight']);
$empty = TRUE;
if (is_array($value)) {
foreach ($value as $k2 => $v2) {
if (!empty($v2)) {
// Stop traversing at the first non empty value.
if (!$ignore_head || $ignore_head && $k2 !== 'row_0') {
$empty = FALSE;
}
}
}
}
else {
if (!empty($value)) {
// Stop traversing at the first non empty value.
$empty = FALSE;
}
}
if ($empty) {
unset($tabledata[$key]);
}
}
return $tabledata;
}