I have two content types, Course, and Class, which represents an instance of a Course. A Course has a a field_time field of type Datetime, a field_location field of type Text, and a field_course field of type Node Reference. In a relatively narrow block I want to display Classes, grouped by Course, and sorted by Time, with each the a line printed for each Course, and then a line under each course that represents each class. For example, given Course1 and Course2 a sample might look like:

Course 1
2009-07-21 New York, NY, USA
2009-08-22 Oslo, Norway
Course 2
2009-07-22 New York, NY USA
2009-08-23 Frankfurt, Germany

Note I don't have room to duplicate the course name on each line. What is the easiest way to accomplish this with Views2?

I have tried it with Styles of HTML List and Table, and Grid, and various options but cannot see how to have the Course (the grouping field) be omitted on each line, but displayed for each group.

I have been using Views2 6.x-2.x-dev. I have been using style table, setup Relationships: content:Course.
Under Fields I have entered
Content: Time-From date Short, (label: none)
Content: Location, (label:none)
Content: Course (Exclude from display, label: none)

Under Sort criteria I have
Content: Location: Asc
Content: Time-From Date asc
(Note: I wanted to sort by course, but could not find that as a sort Criteria)

Under Filters:
Date: Date (node) Content: Time (field_time) – From date >- now.
Node: Published Yes
Node: Type = Class

The table settings show
Content: Time (field_time)-From date, Separator “,”
Conent: Location (field_location)
Content: Course (field_course)
Grouping Field: Content: Course(field_course).

Query

SELECT node.nid AS nid,
   node_data_field_time.field_time_value AS node_data_field_time_field_time_value,
   node_data_field_time.field_time_value2 AS node_data_field_time_field_time_value2,
   node.type AS node_type,
   node.vid AS node_vid,
   node_data_field_location.field_location_value AS node_data_field_location_field_location_value,
   node_data_field_course.field_course_nid AS node_data_field_course_field_course_nid
 FROM node node 
 INNER JOIN content_field_area node_data_field_area ON node.vid = node_data_field_area.vid
 LEFT JOIN content_field_time node_data_field_time ON node.vid = node_data_field_time.vid
 LEFT JOIN content_field_location node_data_field_location ON node.vid = node_data_field_location.vid
 LEFT JOIN content_type_class node_data_field_course ON node.vid = node_data_field_course.vid
 WHERE ((node_data_field_area.field_area_value IN ('Americas', 'Europe', 'Asia-Pacific')) AND (node.status <> 0) AND (node.type in ('class')))
    AND (DATE_FORMAT(node_data_field_time.field_time_value, '%Y-%m-%d') >= '2009-07-30')
   ORDER BY node_data_field_time_field_time_value ASC

exported view

$view = new view;
$view->name = 'classes_by_course_short';
$view->description = 'list classes by Course with short amount of data (home page)';
$view->tag = 'classes';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'field_course_nid' => array(
    'label' => 'Class-Course',
    'required' => 1,
    'delta' => -1,
    'id' => 'field_course_nid',
    'table' => 'node_data_field_course',
    'field' => 'field_course_nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'field_time_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 1,
      'max_length' => '19',
      'word_boundary' => 0,
      'ellipsis' => 0,
      'strip_tags' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'short',
    'multiple' => array(
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => TRUE,
    ),
    'repeat' => array(
      'show_repeat_rule' => '',
    ),
    'fromto' => array(
      'fromto' => 'value',
    ),
    'exclude' => 0,
    'id' => 'field_time_value',
    'table' => 'node_data_field_time',
    'field' => 'field_time_value',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'field_location_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_location_value',
    'table' => 'node_data_field_location',
    'field' => 'field_location_value',
    'relationship' => 'none',
  ),
  'field_course_nid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 1,
    'id' => 'field_course_nid',
    'table' => 'node_data_field_course',
    'field' => 'field_course_nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_time_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_time_value',
    'table' => 'node_data_field_time',
    'field' => 'field_time_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'field_area_value_many_to_one' => array(
    'operator' => 'or',
    'value' => array(
      'Americas' => 'Americas',
      'Europe' => 'Europe',
      'Asia-Pacific' => 'Asia-Pacific',
    ),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 1,
      'operator' => 'field_area_value_many_to_one_op',
      'identifier' => 'field_area_value_many_to_one',
      'label' => 'Content: Area (field_area) - Allowed values',
      'optional' => 1,
      'single' => 0,
      'remember' => 1,
      'reduce' => 1,
    ),
    'id' => 'field_area_value_many_to_one',
    'table' => 'node_data_field_area',
    'field' => 'field_area_value_many_to_one',
    'relationship' => 'none',
    'reduce_duplicates' => 0,
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'date_filter' => array(
    'operator' => '>=',
    'value' => array(
      'min' => NULL,
      'max' => NULL,
      'value' => NULL,
      'default_date' => 'now',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'date_fields' => array(
      'node_data_field_time.field_time_value' => 'node_data_field_time.field_time_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => 'now',
    'default_to_date' => '',
    'year_range' => '-3:+3',
    'id' => 'date_filter',
    'table' => 'node',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'relationship' => 'none',
  ),
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'class' => 'class',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'Classes by Course');
$handler->override_option('footer', 'more on training http://training');
$handler->override_option('footer_format', '2');
$handler->override_option('footer_empty', 0);
$handler->override_option('items_per_page', 4);
$handler->override_option('use_pager', '1');
$handler->override_option('use_more', 1);
$handler->override_option('distinct', 0);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => 'field_course_nid',
  'override' => 0,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'field_time_value' => 'field_time_value',
    'field_location_value' => 'field_location_value',
    'field_course_nid' => 'field_course_nid',
  ),
  'info' => array(
    'field_time_value' => array(
      'sortable' => 0,
      'separator' => ',',
    ),
    'field_location_value' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'field_course_nid' => array(
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('relationships', array());
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => 'field_area_value',
  'type' => 'ul',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'field_time_value' => 'field_time_value',
    'field_location_value' => 'field_location_value',
    'field_course_nid' => 'field_course_nid',
    'field_register_url' => 'field_register_url',
  ),
  'separator' => ',',
));
$handler->override_option('block_description', 'classes_by_course_short');
$handler->override_option('block_caching', -1);

Comments

esmerel’s picture

Status: Active » Closed (fixed)

This issue is a year old, it's likely either resolved or no longer relevant.