Hello,
The unformatted style allow to display views-row-even and views-row-odd classes. But is it possible to display the node tid as class?
Thanks

Comments

dawehner’s picture

Status: Active » Postponed

sry.

can you say what for a view you created?
is this a node or a term view?

export your view thx!

spasmody’s picture

so, it is simple. Here is an extract of the output of the view (I think I don't need to export it) :

<div class="view-content">
	<div class="views-row-1 views-row-odd views-row-first">
		<div>...</div>
		<div>...</div>
	</div>
	<div class="views-row-2 views-row-even">
		<div>...</div>
		<div>...</div>
	</div>
	...
</div>

and so on...
My goal is to display the taxonomy category of the node in addition to views-rows...
For example if the node is a 'cat1' node then display something like that :

<div class="views-row-2 views-row-even cat1">...

or alternatively the tid of the node, in order to theme the rows according to taxonomy using css.

So I use unformatted style with fields row style.
I guess this feature is easy to obtain but I don't know what to write in the views-view-unformatted.tpl.php file.
Please help me. I really need it.
AV

dawehner’s picture

Category: feature » support
Status: Postponed » Fixed

this is preprocess script which does this:

it adds term-$tid to the class.

<?php
function garland_preprocess_views_view_unformatted(&$vars) {
  $view     = $vars['view'];
  $rows     = $vars['rows'];

  if ($view->base_table == 'node') {
    foreach ($view->result as $id => $item) {
      $node = node_load($item->nid);
      $terms = array_keys($node->taxonomy);
      if ($terms) {
        $classes = '';
        foreach ($terms as $tid) {
          $classes .= " term-$tid";
        }
        $vars['classes'][$id] .= $classes;
      }
    }
  }
}
?>
spasmody’s picture

Where do you put the script exactly? For Drupal 6x a themeName_preprocess_hook has to be put in the theme's template.php file but it doesn't work. I actually use garland but I don't obtain the expected result. Is it the right hook? Why not a template_preprocess_hook?

spasmody’s picture

Status: Fixed » Active
dawehner’s picture

did you just copied this code into your garland template.php?

then you have to remove clear theme registry cache and all will be fine.

spasmody’s picture

Status: Active » Fixed

Yes definitely, it is working fine!
Thank you dereine

spasmody’s picture

Status: Fixed » Active

I spoke too quickly. There remains a persistence problem of the display of classes. When I save a classified node (with some taxonomy term), all the unclassified nodes (without term) take the term class. Then I have to republish them to override the display of the class. Do you understand? Is the category required?

spasmody’s picture

Status: Active » Fixed

ok the solution is simple :

>
function garland_preprocess_views_view_unformatted(&$vars) {
  $view     = $vars['view'];
  $rows     = $vars['rows'];

  if ($view->base_table == 'node') {
    foreach ($view->result as $id => $item) {
      $node = node_load($item->nid);
      $terms = array_keys($node->taxonomy);
      if ($terms) {
        $classes = '';
        foreach ($terms as $tid) {
          $classes .= " term-$tid";
        }
        $vars['classes'][$id] .= $classes;
      }
	  else {
	    $classes = " no-term";
        $vars['classes'][$id] .= $classes;
      }
    }
  }
}
edeation’s picture

These scripts don't work. The idea of dereine is nice but there is still a problem with the adds of classes, I mean the function and the conditional structure are ok but there is probably something wrong with the code

$classes = '';
...
$vars['classes'][$id] .= $classes;

because terms don't match with nodes taxonomy.
Any idea?

dawehner’s picture

do you have a views of taxonomy terms?

i'm not really sure what you mean here

edeation’s picture

Status: Fixed » Active

yes here is my view :

$view = new view;
$view->name = 'agenda3';
$view->description = 'Browse through nodes by year, month, day, or week. Date browser attachment adds back/next navigation to the top of the page.';
$view->tag = 'Agenda3';
$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('fields', array(
  'field_date_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      '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(
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_to' => '',
      'group' => TRUE,
    ),
    'repeat' => array(
      'show_repeat_rule' => '',
    ),
    'fromto' => array(
      'fromto' => 'value',
    ),
    'exclude' => 0,
    'id' => 'field_date_value',
    'table' => 'node_data_field_date',
    'field' => 'field_date_value',
    'relationship' => 'none',
  ),
  'field_flyer_fid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      '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' => 'vignette 100x100_linked',
    'multiple' => array(
      'group' => 1,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_flyer_fid',
    'table' => 'node_data_field_flyer',
    'field' => 'field_flyer_fid',
    'relationship' => 'none',
  ),
  'field_live_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      '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' => 1,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => 0,
    ),
    'exclude' => 0,
    'id' => 'field_live_value',
    'table' => 'node_data_field_live',
    'field' => 'field_live_value',
    'relationship' => 'none',
  ),
  'field_mc_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      '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_mc_value',
    'table' => 'node_data_field_mc',
    'field' => 'field_mc_value',
    'relationship' => 'none',
  ),
  'field_performers_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      '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' => 'plain',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_performers_value',
    'table' => 'node_data_field_performers',
    'field' => 'field_performers_value',
    'relationship' => 'none',
  ),
  'addtocartlink' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'addtocartlink',
    'table' => 'uc_products',
    'field' => 'addtocartlink',
    'relationship' => 'none',
  ),
  'field_type_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => 'agenda_type',
      '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_type_value',
    'table' => 'node_data_field_type',
    'field' => 'field_type_value',
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'field_date_value' => array(
    'order' => 'ASC',
    'delta' => -1,
    'id' => 'field_date_value',
    'table' => 'node_data_field_date',
    'field' => 'field_date_value',
    'override' => array(
      'button' => 'Supplanter',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'date_argument' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Tous / Toutes',
    'title' => '',
    'default_argument_type' => 'date',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'date_fields' => array(
      'node_data_field_date.field_date_value' => 'node_data_field_date.field_date_value',
    ),
    'year_range' => '-3:+3',
    'date_method' => 'OR',
    'granularity' => 'year',
    'id' => 'date_argument',
    'table' => 'node',
    'field' => 'date_argument',
    'override' => array(
      'button' => 'Supplanter',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'event' => 'event',
      'image' => 0,
      'rotor_item' => 0,
      'forum' => 0,
      'flyer' => 0,
      'lieu' => 0,
      'organisateur' => 0,
      'page' => 0,
      'story' => 0,
      'video' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '7' => 0,
      '2' => 0,
      '6' => 0,
      '5' => 0,
      '4' => 0,
      '9' => 0,
      '3' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'product' => 'product',
      'event' => 'event',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Supplanter',
    ),
    'relationship' => 'none',
  ),
  'field_type_value' => array(
    'operator' => 'or',
    'value' => array(),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'field_type_value_op',
      'identifier' => 'field_type_value',
      'label' => 'Type',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'field_type_value',
    'table' => 'node_data_field_type',
    'field' => 'field_type_value',
    'override' => array(
      'button' => 'Supplanter',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 1,
  ),
  'date_filter' => array(
    'operator' => '=',
    'value' => array(
      'value' => NULL,
      'min' => NULL,
      'max' => NULL,
      'default_date' => '2009',
      'default_to_date' => '',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'date_filter_op',
      'label' => 'Date',
      'use_operator' => 0,
      'identifier' => 'date_filter',
      'optional' => 0,
      'remember' => 0,
    ),
    'date_fields' => array(
      'node_data_field_date.field_date_value' => 'node_data_field_date.field_date_value',
    ),
    'date_method' => 'OR',
    'granularity' => 'day',
    'form_type' => 'date_select',
    'default_date' => '2009',
    'default_to_date' => '',
    'year_range' => '2009:2009',
    'id' => 'date_filter',
    'table' => 'comments',
    'field' => 'date_filter',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('empty', 'La requête n\'a donné aucun résultat.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('style_options', array(
  'grouping' => 'field_date_value',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'field_flyer_fid' => 'field_flyer_fid',
    'title' => 'title',
    'field_lieu_nid' => 'field_lieu_nid',
    'field_live_value' => 'field_live_value',
    'field_mc_value' => 'field_mc_value',
    'field_performers_value' => 'field_performers_value',
    'field_artiste_vj_value' => 'field_artiste_vj_value',
    'field_horaire_value' => 'field_horaire_value',
    'field_tarif_sur_place_value' => 'field_tarif_sur_place_value',
    'field_type_value' => 'field_type_value',
    'field_genre_value' => 'field_genre_value',
  ),
  'separator' => '',
));
$handler = $view->new_display('date_nav', 'Date browser', 'date_nav_1');
$handler->override_option('arguments', array(
  'date_argument' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Tous / Toutes',
    'title' => '',
    'default_argument_type' => 'date',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'empty',
    'date_fields' => array(
      'node_data_field_date.field_date_value' => 'node_data_field_date.field_date_value',
    ),
    'year_range' => '-3:+3',
    'date_method' => 'OR',
    'granularity' => 'month',
    'id' => 'date_argument',
    'table' => 'node',
    'field' => 'date_argument',
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'image' => 0,
      'rotor_item' => 0,
      'forum' => 0,
      'event' => 0,
      'flyer' => 0,
      'lieu' => 0,
      'organisateur' => 0,
      'page' => 0,
      'story' => 0,
      'video' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '7' => 0,
      '2' => 0,
      '6' => 0,
      '5' => 0,
      '4' => 0,
      '9' => 0,
      '3' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => '',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
  ),
));
$handler->override_option('style_plugin', 'date_nav');
$handler->override_option('style_options', NULL);
$handler->override_option('row_options', array(
  'inline' => array(
    'field_date_value' => 'field_date_value',
    'title' => 'title',
    'field_lieu_nid' => 'field_lieu_nid',
    'field_type_value' => 'field_type_value',
    'field_genre_value' => 'field_genre_value',
    'field_artiste_dj_value' => 'field_artiste_dj_value',
    'field_artiste_live_value' => 'field_artiste_live_value',
    'field_performers_value' => 'field_performers_value',
    'field_horaire_value' => 'field_horaire_value',
    'field_tarif_sur_place_value' => 'field_tarif_sur_place_value',
    'field_tarif_prevente_value' => 'field_tarif_prevente_value',
  ),
  'separator' => '-',
));
$handler->override_option('attachment_position', 'both');
$handler->override_option('inherit_arguments', 0);
$handler->override_option('inherit_exposed_filters', 1);
$handler->override_option('displays', array(
  'default' => 0,
  'block_2' => 0,
  'block_1' => 0,
  'block_3' => 0,
  'page_1' => 0,
));
$handler = $view->new_display('block', 'Calendar', 'block_2');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'Notification', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('block', 'lieu', 'block_3');
$handler->override_option('relationships', array(
  'field_lieu_nid' => array(
    'label' => 'Lieu',
    'required' => 1,
    'delta' => -1,
    'id' => 'field_lieu_nid',
    'table' => 'node_data_field_lieu',
    'field' => 'field_lieu_nid',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'field_adresse_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      '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_adresse_value',
    'table' => 'node_data_field_adresse',
    'field' => 'field_adresse_value',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'field_lieu_nid',
  ),
  'field_logo_fid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'Apercu_default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_logo_fid',
    'table' => 'node_data_field_logo',
    'field' => 'field_logo_fid',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'field_lieu_nid',
  ),
  'field_plan_url' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      '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_plan_url',
    'table' => 'node_data_field_plan',
    'field' => 'field_plan_url',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'field_lieu_nid',
  ),
));
$handler->override_option('sorts', array());
$handler->override_option('arguments', array(
  'field_lieu_nid' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Tous / Toutes',
    'title' => '',
    'default_argument_type' => 'php',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'field_lieu_nid',
    'table' => 'node_data_field_lieu',
    'field' => 'field_lieu_nid',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '<?php
              if (!empty($_GET[\'field_lieu_nid\'])) {
                return $_GET[\'field_lieu_nid\'];
              }
            ?>',
    'validate_argument_node_type' => array(
      'image' => 0,
      'rotor_item' => 0,
      'forum' => 0,
      'event' => 0,
      'lieu' => 0,
      'organisateur' => 0,
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '2' => 0,
      '6' => 0,
      '5' => 0,
      '4' => 0,
      '3' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array());
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'agenda');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler = $view->new_display('page', 'Agenda non filtré', 'page_2');
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'event' => 'event',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Supplanter',
    ),
    'relationship' => 'none',
  ),
  'field_type_value' => array(
    'operator' => 'or',
    'value' => array(),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'field_type_value_op',
      'label' => 'Type',
      'use_operator' => 0,
      'identifier' => 'field_type_value',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'field_type_value',
    'table' => 'node_data_field_type',
    'field' => 'field_type_value',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 1,
  ),
  'field_genre_value' => array(
    'operator' => 'or',
    'value' => array(),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'field_genre_value_op',
      'label' => 'Genre',
      'use_operator' => 0,
      'identifier' => 'field_genre_value',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'field_genre_value',
    'table' => 'node_data_field_genre',
    'field' => 'field_genre_value',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 1,
  ),
  'field_lieu_nid' => array(
    'operator' => 'or',
    'value' => array(),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'field_lieu_nid_op',
      'label' => 'Lieu',
      'use_operator' => 0,
      'identifier' => 'field_lieu_nid',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'field_lieu_nid',
    'table' => 'node_data_field_lieu',
    'field' => 'field_lieu_nid',
    'override' => array(
      'button' => 'Utiliser la valeur par défaut',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 1,
  ),
));
$handler->override_option('path', 'agenda-non-filtre');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

where taxonomy is off course enabled for my content type 'event' (in my case only one vocabulary is enabled).
The problem is that the tid classes don't match with the right taxonomy terms.
For instance I have 4 events respectively from tid 1, 2, 1, 2, then strangely I obtain term-1, term-1, term-2, term-1.
I don't understand why.

dawehner’s picture

oh man can you answer what i asced?

edeation’s picture

yes here is my view (I don't know why the php tags don't work)

$view = new view;
$view->name = 'agenda2';
$view->description = 'Browse through nodes by year, month, day, or week. Date browser attachment adds back/next navigation to the top of the page.';
$view->tag = 'Agenda2';
$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('fields', array(
'field_date_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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(
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'group' => TRUE,
),
'repeat' => array(
'show_repeat_rule' => '',
),
'fromto' => array(
'fromto' => 'value',
),
'exclude' => 0,
'id' => 'field_date_value',
'table' => 'node_data_field_date',
'field' => 'field_date_value',
'relationship' => 'none',
),
'field_flyer_fid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 'vignette 100x100_linked',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_flyer_fid',
'table' => 'node_data_field_flyer',
'field' => 'field_flyer_fid',
'relationship' => 'none',
),
'tid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'imagecache_preset' => '',
'link_to_taxonomy' => 0,
'exclude' => 0,
'id' => 'tid',
'table' => 'term_image',
'field' => 'tid',
'relationship' => 'none',
),
'nothing_2' => array(
'label' => '',
'alter' => array(
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'nothing_2',
'table' => 'views',
'field' => 'nothing',
'relationship' => 'none',
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_lieu_nid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => 'agenda_lieu',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'link_to_node' => 1,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_lieu_nid',
'table' => 'node_data_field_lieu',
'field' => 'field_lieu_nid',
'relationship' => 'none',
),
'nothing_1' => array(
'label' => '',
'alter' => array(
'text' => '-',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
),
'exclude' => 0,
'id' => 'nothing_1',
'table' => 'views',
'field' => 'nothing',
'relationship' => 'none',
),
'field_artiste_dj_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_artiste_dj_value',
'table' => 'node_data_field_artiste_dj',
'field' => 'field_artiste_dj_value',
'relationship' => 'none',
),
'nothing_6' => array(
'label' => '',
'alter' => array(
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'nothing_6',
'table' => 'views',
'field' => 'nothing',
'relationship' => 'none',
),
'field_live_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_live_value',
'table' => 'node_data_field_live',
'field' => 'field_live_value',
'relationship' => 'none',
),
'field_mc_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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_mc_value',
'table' => 'node_data_field_mc',
'field' => 'field_mc_value',
'relationship' => 'none',
),
'field_performers_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 'plain',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_performers_value',
'table' => 'node_data_field_performers',
'field' => 'field_performers_value',
'relationship' => 'none',
),
'field_artiste_vj_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_artiste_vj_value',
'table' => 'node_data_field_artiste_vj',
'field' => 'field_artiste_vj_value',
'relationship' => 'none',
),
'addtocartlink' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'addtocartlink',
'table' => 'uc_products',
'field' => 'addtocartlink',
'relationship' => 'none',
),
'view_node' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'text' => 'S\'inscrire',
'exclude' => 0,
'id' => 'view_node',
'table' => 'node',
'field' => 'view_node',
'relationship' => 'none',
),
'nothing' => array(
'label' => '',
'alter' => array(
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'nothing',
'table' => 'views',
'field' => 'nothing',
'relationship' => 'none',
),
'field_horaire_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '| ',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'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_horaire_value',
'table' => 'node_data_field_horaire',
'field' => 'field_horaire_value',
'relationship' => 'none',
),
'field_tarif_sur_place_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'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' => 'fr_0',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_tarif_sur_place_value',
'table' => 'node_data_field_tarif_sur_place',
'field' => 'field_tarif_sur_place_value',
'relationship' => 'none',
),
'field_type_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => 'agenda_type',
'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_type_value',
'table' => 'node_data_field_type',
'field' => 'field_type_value',
'relationship' => 'none',
),
'field_genre_value' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => 'agenda_genre',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '12',
'word_boundary' => 0,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 0,
'label_type' => 'none',
'format' => 'default',
'multiple' => array(
'group' => 1,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_genre_value',
'table' => 'node_data_field_genre',
'field' => 'field_genre_value',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'field_date_value' => array(
'order' => 'ASC',
'delta' => -1,
'id' => 'field_date_value',
'table' => 'node_data_field_date',
'field' => 'field_date_value',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'date_argument' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Tous / Toutes',
'title' => '',
'default_argument_type' => 'date',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'date_fields' => array(
'node_data_field_date.field_date_value' => 'node_data_field_date.field_date_value',
),
'year_range' => '-3:+3',
'date_method' => 'OR',
'granularity' => 'year',
'id' => 'date_argument',
'table' => 'node',
'field' => 'date_argument',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'event' => 'event',
'image' => 0,
'rotor_item' => 0,
'forum' => 0,
'flyer' => 0,
'lieu' => 0,
'organisateur' => 0,
'page' => 0,
'story' => 0,
'video' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
'7' => 0,
'2' => 0,
'6' => 0,
'5' => 0,
'4' => 0,
'9' => 0,
'3' => 0,
),
'validate_argument_type' => 'tid',
'user_argument_type' => '',
'restrict_user_roles' => 0,
'user_roles' => array(),
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'product' => 'product',
'event' => 'event',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
),
'field_type_value' => array(
'operator' => 'or',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'field_type_value_op',
'identifier' => 'field_type_value',
'label' => 'Type',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'field_type_value',
'table' => 'node_data_field_type',
'field' => 'field_type_value',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
'reduce_duplicates' => 1,
),
'field_genre_value' => array(
'operator' => 'or',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'field_genre_value_op',
'identifier' => 'field_genre_value',
'label' => 'Genre',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'field_genre_value',
'table' => 'node_data_field_genre',
'field' => 'field_genre_value',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
'reduce_duplicates' => 1,
),
'field_lieu_nid' => array(
'operator' => 'or',
'value' => array(),
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 0,
'operator' => 'field_lieu_nid_op',
'identifier' => 'field_lieu_nid',
'label' => 'Lieu',
'optional' => 1,
'single' => 1,
'remember' => 0,
'reduce' => 0,
),
'id' => 'field_lieu_nid',
'table' => 'node_data_field_lieu',
'field' => 'field_lieu_nid',
'override' => array(
'button' => 'Supplanter',
),
'relationship' => 'none',
'reduce_duplicates' => 1,
),
'date_filter' => array(
'operator' => '=',
'value' => array(
'value' => NULL,
'min' => NULL,
'max' => NULL,
'default_date' => '2009',
'default_to_date' => '',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => 'date_filter_op',
'label' => 'Date',
'use_operator' => 0,
'identifier' => 'date_filter',
'optional' => 0,
'remember' => 0,
),
'date_fields' => array(
'node_data_field_date.field_date_value' => 'node_data_field_date.field_date_value',
),
'date_method' => 'OR',
'granularity' => 'day',
'form_type' => 'date_select',
'default_date' => '2009',
'default_to_date' => '',
'year_range' => '2009:2009',
'id' => 'date_filter',
'table' => 'comments',
'field' => 'date_filter',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('empty', 'La requête n\'a donné aucun résultat.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('style_options', array(
'grouping' => 'field_date_value',
));
$handler->override_option('row_options', array(
'inline' => array(
'field_flyer_fid' => 'field_flyer_fid',
'title' => 'title',
'field_lieu_nid' => 'field_lieu_nid',
'field_live_value' => 'field_live_value',
'field_mc_value' => 'field_mc_value',
'field_performers_value' => 'field_performers_value',
'field_artiste_vj_value' => 'field_artiste_vj_value',
'field_horaire_value' => 'field_horaire_value',
'field_tarif_sur_place_value' => 'field_tarif_sur_place_value',
'field_type_value' => 'field_type_value',
'field_genre_value' => 'field_genre_value',
),
'separator' => '',
));

where taxonomy is off course enabled for my content type 'event' (in my case only one vocabulary is enabled).
The problem is that the tid classes don't match with the right taxonomy terms.
For instance I have 4 events respectively from tid 1, 2, 1, 2, then strangely I obtain term-1, term-1, term-2, term-1.
I don't understand why.

dawehner’s picture

do you want to do once

<?php
$node = node_load($item->nid);
print '<pre>'. print_r($node->taxonomy, TRUE) .'</pre>';
?>

I think then you / or i :) can see the content, perhaps its then possible to help

spasmody’s picture

edeation’s picture

ok the problem is confirmed.
I get

Array
(
    [48] => stdClass Object
        (
            [tid] => 48
            [vid] => 12
            [name] => PassPass
            [description] => 
            [weight] => 0
        )

)

Array
(
    [50] => stdClass Object
        (
            [tid] => 50
            [vid] => 12
            [name] => Aucune invitation
            [description] => 
            [weight] => 0
        )

)

Array
(
    [48] => stdClass Object
        (
            [tid] => 48
            [vid] => 12
            [name] => PassPass
            [description] => 
            [weight] => 0
        )

)

Array
(
    [50] => stdClass Object
        (
            [tid] => 50
            [vid] => 12
            [name] => Aucune invitation
            [description] => 
            [weight] => 0
        )

)

while the view return

<div class="views-row-1 views-row-odd views-row-first term-48">
...
<div class="views-row-2 views-row-even term-48">
...
<div class="views-row-3 views-row-odd term-48">
...
<div class="views-row-4 views-row-even views-row-last term-50">

There is a critical problem regarding the second node. It is a bug of my view?

dawehner’s picture

<?php
function garland_preprocess_views_view_unformatted(&$vars) {
  $view     = $vars['view'];
  $rows     = $vars['rows'];

  if ($view->base_table == 'node') {
    foreach ($view->result as $id => $item) {
      $node = node_load($item->nid);
      $terms = array_keys($node->taxonomy);
      $classes = '';
      if ($terms) {
        foreach ($terms as $tid) {
          $classes .= " term-$tid";
        }
        $vars['classes'][$id] .= $classes;
      }
      else {
        $classes = " no-term";
        $vars['classes'][$id] .= $classes;
      }
    }
  }
}
?>

Perhaps try out this.

edeation’s picture

now I obtain

<div class="views-row-1 views-row-odd views-row-first term-48">
...
<div class="views-row-2 views-row-even term-48">
...
<div class="views-row-3 views-row-odd term-50">
...
<div class="views-row-4 views-row-even views-row-last term-48">

it is incomprehensible

edeation’s picture

Category: support » bug
Status: Active » Closed (won't fix)

I totally rebuilded my view and I finally found the origin of problem. When I specify a field by which to group the records, the preprocess script doesn't work but if I leave blank to not group, the script works fine. I think the preprocess script is incompatible with grouping field option in views. It is a bit exasperating. Can I add something at the script to solve the problem?

edeation’s picture

Status: Closed (won't fix) » Active
aren cambre’s picture

I don't understand why the solution is to modify the Drupal theme. Wouldn't the best solution be for Views to add a node's term-$tids to the list of CSS classes for each row?

dboulet’s picture

Regarding #20, the reason that the code doesn't work when using a grouping field is because it uses data from $vars['view']->result, which contains the data for all results, and not just the results specific to that group. That means that, when using a grouping field, the data in the first row in the table no longer necessarily corresponds to the data in the first item in $vars['view']->result. I've submitted a patch that would allow a work around for this problem, see #536994: Store row data for future use in views table preprocess functions.

aschiwi’s picture

#22: do you have working code to do that?

#23: Looks like the patch has been committed, so I installed latest Views dev but I still get the wrong output for the term id. Too bad you can't output views fields in views-view-unformatted.tpl.php...

mattez’s picture

I wanted to simplify views list classes from something like this

<li class="views-row views-row-3 views-row-odd">

to

<li class="row-3 odd">

I problem was I had views formatted as HTML list.
So if I want to override (simplify) classes in view I should do it in template_preprocess_views_view_unformatted like above.
BUT function for list is template_preprocess_views_view_list so a have to override it to.
My solution:

function MYTHEME_preprocess_views_view_list(&$vars) {
  MYTHEME_preprocess_views_view_unformatted($vars);
}

function MYTHEME_preprocess_views_view_unformatted(&$vars) {
  $view     = $vars['view'];
  $rows     = $vars['rows'];

  $vars['classes'] = array();
  // Set up striping values.
  foreach ($rows as $id => $row) {
    $vars['classes'][$id] = 'row-' . ($id + 1);
    $vars['classes'][$id] .= ($id % 2 ? ' even' : ' odd');
    if ($id == 0) {
      $vars['classes'][$id] .= ' first';
    }
  }
  $vars['classes'][$id] .= ' last';
}
dawehner’s picture

Status: Active » Fixed

SO this is fixed

aren cambre’s picture

Status: Fixed » Active

I think these are all workarounds until #22 is satisfied.

merlinofchaos’s picture

Category: bug » support
Status: Active » Fixed

I don't understand why the solution is to modify the Drupal theme. Wouldn't the best solution be for Views to add a node's term-$tids to the list of CSS classes for each row?

No, if you go down that road you're going to have to add anything anybody might want, ever, as a class. That is incredibly silly.

This has been marked a bug but I don't see what the bug being reported is. As far as I can tell, this is a support request and it's been answered.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.