Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a list of teasers on any given page, and say I wanted the first teaser background to be gray, the next to be green, the third to be gray again, and so on. Can that be done while creating the templates, or is that something that needs to be coded deeper in the module?
Comments
Comment #1
jrglasgow CreditAttribution: jrglasgow commentedyou could put the teaser each in a div with a different class like so:
then you need to theme your site to have different backgrounds for 'teaser_even' and 'teaser_odd' classes
Comment #2
joepril CreditAttribution: joepril commentedI think I suck at explaining what I've done. Lemme try again. So I have just one teaser template for multiple items. I then use Views to sort the various items onto separate pages, while they all use the same teaser template. On those views pages (based on price), is there a way to make the teasers alternate background colors. Don't know if what you explained would work in that situation.
Comment #3
jrglasgow CreditAttribution: jrglasgow commentedI understood your request as you just explained it. The code I provided above should work as you desire, I haven't tested the code, but I believe it will work.