views_table_rowspan.module in Views Table Rowspan 7
Same filename and directory in other branches
Merge duplicate rows in group to one row.
File
views_table_rowspan.moduleView source
<?php
/**
* @file
* Merge duplicate rows in group to one row.
*/
/**
* Implements hook_help().
*/
function views_table_rowspan_help($path, $arg) {
switch ($path) {
// Help for module views_table_rowspan.
case 'admin/help#views_table_rowspan':
$help = '<p>' . t('Views Table Rowspan defines new views display format name "Table Rowspan". This display will group rows in table and merge row has same value to one row use property !url.', array(
'!url' => '<a href="http://www.w3schools.com/tags/att_td_rowspan.asp">rowspan</a>',
)) . '</p>';
$help .= '<ul>';
$help .= '<li>' . t('Create a !link (for example, a list of node).', array(
'!link' => l(t('new view'), 'admin/structure/views/add'),
)) . '</li>';
$help .= '<li>' . t('Set format Table Rowspan for this view.') . '</li>';
$help .= '<li>' . t('Add some field to this view.') . '</li>';
$help .= '<li>' . t('Group field that has same value.') . '</li>';
$help .= '<li>' . t('Check option "Merge rows in group".') . '</li>';
$help .= '</ul>';
return $help;
}
}
/**
* Implements hook_views_api().
*/
function views_table_rowspan_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'views_table_rowspan') . '/views',
);
}
/**
* Implements hook_theme_registry_alter().
*/
function views_table_rowspan_theme_registry_alter(&$theme_registry) {
if (isset($theme_registry['views_view_table'])) {
$theme_registry['views_view_table']['preprocess functions'][] = 'views_table_rowspan_preprocess_callback';
}
}
/**
* Theme preprocess callback.
*/
function views_table_rowspan_preprocess_callback(&$vars) {
$view = $vars['view'];
// Rows to separate group in table.
$seperator_rows = array();
if (isset($view->rowspan)) {
foreach ($view->rowspan as $field_name => $rowspan) {
foreach ($rowspan as $row_index => $num_span) {
$vars['field_attributes'][$field_name][$row_index] = array(
'rowspan' => count($num_span),
);
$vars['field_classes'][$field_name][$row_index] .= ' cell-rowspan';
if ($field_name == $view->style_options['grouping'][0]['field']) {
$seperator_rows[] = $num_span[count($num_span) - 1];
}
// Hide other columns.
array_shift($num_span);
foreach ($num_span as $row_span_index) {
$vars['field_attributes'][$field_name][$row_span_index] = array(
'style' => 'display:none',
);
}
}
}
}
$seperator_rows = array_unique($seperator_rows);
foreach ($view->field as $view_field_name => $view_field) {
foreach ($seperator_rows as $row_index) {
$vars['field_classes'][$view_field_name][$row_index] .= ' cell-seperator';
}
}
}
Functions
Name | Description |
---|---|
views_table_rowspan_help | Implements hook_help(). |
views_table_rowspan_preprocess_callback | Theme preprocess callback. |
views_table_rowspan_theme_registry_alter | Implements hook_theme_registry_alter(). |
views_table_rowspan_views_api | Implements hook_views_api(). |