Alternating Teaser Classes
Last modified: August 12, 2008 - 17:03
If you want to change the theme on alternating teasers, here is a quick way to accomplish this. First open your node.tpl.php (or whatever content type file you have created) and find:
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">Now, copy and paste the following code:
<?php global $node_count; print ($node_count++ % 2) ? 'odd' : 'even'; ?>And paste it into the original code (into the class not the id). It should now look like this:
<div id="node-<?php print $node->nid; ?>" class="node-<?php global $node_count; print ($node_count++ % 2) ? 'odd' : 'even'; ?><?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">When you save your file to your theme directory you will node "odd" and "even" being added on each teaser.
NOTE: This should also work with Drupal 4.x but the structure of the node.tpl.php is slightly different but should work fine.
Originally from http://drupal.org/node/12171.
