function _multifield_table_hide_empty in Multifield table 7
Remove columns that are entirely empty.
1 call to _multifield_table_hide_empty()
- template_preprocess_table__multifield_table in theme/
theme.inc - Implements template_preprocess_table__multifield_table().
File
- theme/
theme.inc, line 179 - Theme functions for the Mutifield Table module.
Code
function _multifield_table_hide_empty(&$variables) {
$rows = $variables['rows'];
$count = array();
foreach ($rows as $row_delta => $row) {
foreach ($row['data'] as $column_delta => $column) {
if (!isset($count[$column_delta])) {
$count[$column_delta] = 0;
}
if (isset($column['data']['#empty'])) {
$count[$column_delta]++;
}
}
}
foreach ($count as $column_delta => $column) {
if ($column === count($rows)) {
foreach ($rows as $row_delta => $row) {
unset($variables['rows'][$row_delta]['data'][$column_delta]);
unset($variables['header'][$column_delta]);
}
}
}
}