Alternating Alignments On Full Node Views With Contemplate

Posted on: 2008-07-14 23:43:59

While converting my "Netoteric":http://netoteric.com/ site to "Drupal":http://drupal.org/, there was a small problem with the "portfolio":http://netoteric.com/portfolio page. The items in it alternate between left and right. Views Theme Wizard didn't work. It was time for more desperate measures.

I added a function in my custom template file, which created an index number and assigned it to a node member.

<code type="php">/**

theme_views_view_nodes_portfolio overrides the "Views":http://drupal.org/project/views default theme function, but only for the portfolio view.

Then inside the contemplate body template I just added a modulo function to alternate between left and right:

<code type="php"><div class="thumbnail __views_index_number % 2 ? 'right':'left')?>">

And voila! Now the images alternate between left and right...