Im attempting to create zebra stripes for a page I recently created. The page basically spits out X number of nodes of 'flexinode-1' type.

I have the page up and running fine, and I can style each element with no problems. My question now is, how can I add the Zebra Striping element to this page?

Each of my nodes is visually seperated by the border-bottom: solid 1px #000; css style.

My flexinode-1.tpl.php file is extremely small...the entire code is this:

<div class="class-name-used-for-styling">
   <?php print ($main ? strip_tags($content, '<a><p><br><br />') : $content) ?>
  </div>

I've read about adding :

<?php
function _phptemplate_variables($hook, $vars) {
    static $count;
    $count = is_array($count) ? $count : array();
    $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;
    $vars['zebra'] = ($count[$hook] % 2) ?'odd' : 'even';
    $vars['seqid'] = $count[$hook]++;
    return $vars;
  }
?> 

into my pages, but I'm not exactly sure where I should be adding this, or if I have to specify the flexinode type anywhere.

All help is appreciated. Thanks,
-=Vince

Comments

casey’s picture

<div class="class-name-used-for-styling <?php print $zebra ?>">
  <?php print ($main ? strip_tags($content, '<a><p><br><br />') : $content) ?>
  </div>
oziumjinx’s picture

I'll give this a shot and let you know.

Where can I find the
or styles associated with $zebra so I can define what colors I'd like to set?

Thanks very much,
-=Vince

oziumjinx’s picture

Will I need to use the larger block of code that I posted in the original forum post? Or can I just add that reference to $zebra?

Technology White Papers

budda’s picture

Zebra striping support is part of phptemplate engine.

  $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';

So the CSS class added is either 'odd' or 'even'.

--
Drupal consultancy

oziumjinx’s picture

Thank you for this, I appreciate it. Within what class should I declare the 'odd' and 'even' sub classes within?

Technology White Papers

oziumjinx’s picture

Got this running properly. I really appreciate the help

Technology White Papers

mrmachine’s picture

Got this running properly. I really appreciate the help

uh, how? would be nice to know ;)

did you end up having to include that function in template.php, or not? i've got a similar problem here: http://drupal.org/node/97879 - perhaps you might have an insight in to what i need to do?

nicholasthompson’s picture

Wow! I did NOT know it was that easy! Stripey websites, here I come!