Appliquer Zebra sur block conteneur de view ?

Information importante

En raison d'un grand nombre d'inscriptions de spammers sur notre site, polluant sans relache notre forum, nous suspendons la création de compte via le formulaire de "sign up".

Il est néanmoins toujours possible de devenir adhérent•e en faisant la demande sur cette page, rubrique "Inscription" : https://www.drupal.fr/contact


De plus, le forum est désormais "interdit en écriture". Il n'est plus autorisé d'y écrire un sujet/billet/commentaire.

Pour contacter la communauté, merci de rejoindre le slack "drupalfrance".

Si vous voulez contacter le bureau de l'association, utilisez le formulaire disponible ici, ou envoyez-nous un DM sur twitter.

Les variables de zebra sont bien spécifiées mais elles ne sont pas prises en compte à l'affichage.

$vars['stripe'] = $i % 2 ? 'even' : 'odd';

Selon-vous où ais-je pêché?

mon code dans template.php

/**
* views template to output a view.
* This code was generated by the views theming wizard
* Date: mer, 06/20/2007 - 23:16
* View: v_titre_jour
*
* This function goes in your template.php file
*/
function phptemplate_views_view_list_v_titre_jour($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

  // Set up the fields in nicely named chunks.
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

  // Set up some variables that won't change.
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
    $vars['count'] = $i;
    $vars['stripe'] = $i % 2 ? 'even' : 'odd';
    foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
        $vars[$name . '_label'] = $field['label'];
      }
    }
    $items[] = _phptemplate_callback('views-list-v_titre_jour', $vars);
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

mon block-titre_jour.tpl

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

<?php if ($block->subject): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

  <div class="content"><?php print $block->content ?></div>
</div>

ma views-list-v_titre_jour

<?php
/**
 * views template to output one 'row' of a view.
 * This code was generated by the views theming wizard
 * Date: mer, 06/20/2007 - 23:16
 * View: v_titre_jour
 *
 * Variables available:
 * $view -- the entire view object. Important parts of this object are
 *   v_titre_jour, .
 * $view_type -- The type of the view. Probably 'page' or 'block' but could
 *   also be 'embed' or other string passed in from a custom view creator.
 * $node -- the raw data. This is not a real node object, but will contain
 *   the nid as well as other support fields that might be necessary.
 * $count -- the current row in the view (not TOTAL but for this page) starting
 *   from 0.
 * $stripe -- 'odd' or 'even', alternating. * $field_logoarticle_fid --
 * $field_logoarticle_fid_label -- The assigned label for $field_logoarticle_fid
 * $field_surtitre_value --
 * $field_surtitre_value_label -- The assigned label for $field_surtitre_value
 * $title -- Montre l titre du noeud
 * $title_label -- The assigned label for $title
 * $field_sous_titre_value --
 * $field_sous_titre_value_label -- The assigned label for $field_sous_titre_value
 * $field_chapo_value --
 * $field_chapo_value_label -- The assigned label for $field_chapo_value
 * $field_logosurvol_fid --
 * $field_logosurvol_fid_label -- The assigned label for $field_logosurvol_fid
 *
 * This function goes in your views-list-v_titre_jour.tpl.php file
 */
 

 //now we add the stylesheet...
 
drupal_add_css(path_to_theme() .'/views-list-v_titre_jour.css');
 
 
?>



<div class="view-field view-data-field_logoarticle_fid-value">
  <?php print $field_logoarticle_fid?>
</div>



<div class="view-field view-data-field-surtitre-value">
  <?php print $field_surtitre_value?>
</div>


<div class="view-field view-data-title">
  <?php print $title?>
</div>


<div class="view-field view-data-field-sous-titre-value">
  <?php print $field_sous_titre_value?>
</div>


<div class="view-field view-data-field-chapo-value">
  <?php print $field_chapo_value?>
</div>
Forum : 
Version de Drupal :