Add
$items['taxonomygroup_table'] = array(
'name' => t("Grouped By Taxonomy Term, Table"),
'theme' => "taxonomygroup_group_table",
'summary_theme' => "views_summary",
);
}
in the function views_group_pack_views_style_plugins in the views_group_pack_module
Then add this in taxonomygroup.inc and clear the views cache.
function theme_taxonomygroup_group_table($view, $nodes, $type) {
drupal_add_css(drupal_get_path('module', 'views_group_pack').'/taxonomygroup.css');
if (isset($view->sort[0]['field'])) {
$sort_field = $view->sort[0]['field'];
} // if it's got a sort field
if ($sort_field != 'term_data.weight') {
drupal_set_message(t("The view must be sorted first by a 'taxonomy term' field, in order to be Grouped By Taxonomy Term."), 'error');
return theme('views_view_teasers', $view, $nodes, $type);
} // if the sort field isn't set
$by_taxonomy = array();
foreach ($nodes as $proto_node) {
$node = node_load($proto_node->nid);
$val = array_values($node->taxonomy);
$term = $val[0]->name;
$by_taxonomy[$term][] = $node;
} // foreach node
return theme("taxonomygroup_taxonomylist", $view, $by_taxonomy, $type);
}
function theme_taxonomygroup_taxonomytable($view, $by_taxonomy, $type) {
$output = "<div id=\"taxonomygroup\" class=\"taxonomygroup\">";
foreach ($by_taxonomy as $term => $termlist) {
$output .= theme('taxonomygroup_listterm', $termlist, $term, $view);
} // foreach term
$output .= "</div><!-- taxonomygroup -->";
return $output;
}
function theme_taxonomygroup_tableterm($termtable, $term, $view) {
$output = "";
$output .= "<div id=\"taxonomygroup-{$term}-header\" class=\"taxonomygroup-header taxonomygroup-{$term}-header\">{$term}</div>";
$output .= "<div class=\"taxonomygroup-content taxonomygroup-{$term}-content\">";
$fields = _views_get_fields();
foreach ($termlist as $node) {
$row = array();
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== FALSE) {
// THE FOLLOWING LINE IS EXTREMELY DIRTY
$field['queryname']='title'; // EXTREMELY DIRTY
// THE PRECEDENT LINE IS EXTREMELY DIRTY
/* THE REASON OF THAT DIRTY TRICK IS THAT views_handler_field_nodelink will be called with $node -> $field['queryname'] for the $value parameter, making it to be empy because $niode doesn't have a node_title field as proposed by $field[''queryname']. $node just have title field. So I change that in the field array, not without shame. */
$cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
// dprint_r($field);
$cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']);
$row[] = $cell;
}
}
$rows[] = $row;
}
return theme('table', $view->table_header, $rows);
}
Comments
Comment #1
jmary commentedComment #2
jmary commentedThere was a mistake in the precedant code preventing it to work. It should be correct now.
Comment #3
jmary commentedI have rewritten all of that - consequently :
1. It is much shorter.
2. More logical
3. Clean
I'll post this there soon.
Comment #4
whan commentedI too had the same requirement. The coding helped me a lot. But I need to display other cck field types also in the table, only the node title and the taxonomy term are getting displayed in the grouped table view. Need help in displaying other fields also in the table.
Thanks.
Comment #5
jmary commentedIn the file views_group_pack.module,modify the the function views_group_pack_views_style_plugins :
Then in the file taxonomygroup.inc add the functions :
All of that would deserve that the maintainer of the module is releasing a new version but he looks dead for his paerticipations on that.
I've put the archive of all the files as I am using them on prod.
Comment #6
hanskuiters commentedCame across this issue today. It is just what I needed.
@jmary: thank you very much.