Option to not display empty rows
hefox - August 26, 2009 - 14:47
| Project: | Editview |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
In general tables don't show the empty rows, so it'd be cool if the empty rows weren't shown also.
Below is how I added it, by only adding header after checking if data was empty else continueing.
Can make a patch if desired. Could be good if it's a confirgurable option
<?php
foreach ($view->field as $field) {
// If auto_nodetitle module is enabled and the title field is to be overridden don't display it.
if (module_exists('auto_nodetitle') && $field->real_field == 'title') {
if (auto_nodetitle_get_setting($form['#node']->type) == AUTO_NODETITLE_ENABLED) {
continue;
}
}
$classes = array();
$cell = array('data' => '');
foreach (module_implements('field_form_render') as $module) {
$function = $module .'_field_form_render';
$result = $function($form, $field);
foreach ($result as $key => $value) {
switch ($key) {
case 'data':
$cell['data'] .= $value;
break;
case 'class':
$classes[] = $value;
break;
default:
$cell[$key] = $value;
break;
}
}
}
if (!$cell['data']) continue;
$cell['class'] = implode(' ', $classes);
$header[] = $field->label();
$row[] = $cell;
}
?>