charlatan Posted January 23, 2006 Posted January 23, 2006 Hi, I was wondering if anyone has changed to product result (index page) to show different colours for alternate rows in a table. So cay on a category "For Him" the first product in the table has a background colour of white, and the next row has a background colour of grey. This should be easy but it is proving a pain I am modifying the right part? $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } }
draxion Posted January 23, 2006 Posted January 23, 2006 you control the color of the row in the stylesheet.css. file. Look for the following lines and change to whatever color you want. TR.accountHistory-odd, TR.addressBook-odd, TR.alsoPurchased-odd, TR.payment-odd, TR.productListing-odd, TR.productReviews-odd, TR.upcomingProducts-odd, TR.shippingOptions-odd { background: #ffffff; } TR.accountHistory-even, TR.addressBook-even, TR.alsoPurchased-even, TR.payment-even, TR.productListing-even, TR.productReviews-even, TR.upcomingProducts-even, TR.shippingOptions-even { background: #eeeeee; } Is this what you're looking for? Hope that helps. Shayne
charlatan Posted January 23, 2006 Author Posted January 23, 2006 Thanks for the reply, erm sort of What i want is something like if bgcol1 ="blue" then bgcol1="green" else bgcol1="blue" end if so the row just alternates the background colour on the products page Am i even close with this $bgcol1 = blue; $rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { if $bgcol1 ="blue" then $bgcol1="green" else $bgcol1="blue" end if $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" bgcolor='. $bgcol1 . ' class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } }
charlatan Posted January 23, 2006 Author Posted January 23, 2006 sorry for the double post what i have now which doesn't throw any error's but also doesn't switch the colour of the background...this is the correct part for the single product TD's? $bgcol1 = 'blue';$rows = 0; while ($categories = tep_db_fetch_array($categories_query)) { if ( $bgcol1 == 'blue' ){ $bgcol1 = 'green'; } else { $bgcol1 = 'blue'; } $rows++; $cPath_new = tep_get_path($categories['categories_id']); $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%'; echo ' <td align="center" bgcolor="'. $bgcol1 . '" class="smallTextss" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n"; if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) { echo ' </tr>' . "\n"; echo ' <tr>' . "\n"; } }
Guest Posted January 23, 2006 Posted January 23, 2006 is the class="smallTextss" that you're using for the cells correct? Make sure there is no bgnd color assigned to it since you're trying to control it outside css.
charlatan Posted January 23, 2006 Author Posted January 23, 2006 Arr yeah thanks :) ...i changed it so it had no style for that purpose, it was smallTexts...should of just taken it out.. when i save the page from internet explorer to disk i look at the code and see each TD is looking at class=productListing-data, I'm getting a lil bit confused with it :blink: is the rows i'd like to change
Recommended Posts
Archived
This topic is now archived and is closed to further replies.