Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Item Listing alternating text colors


markem2

Recommended Posts

Posted

I do not know if anyone else has run in to this or not or if it has been discussed before.

 

That being said - I recently downloaded the latest version of OSCommerce and have been trying it out.  I just finished writing a new website for our company but thought that it would be nice to compare the two.  I have been very impressed with the current version and actually am thinking of throwing out everything I have done and switching everything over to OSCommerce.

 

Anyway, On the part of OSCommerce where the products are listed in a single column - if you use a bland black and white setup for the site - then you can run in to problems.  If you use black for the text - then every other column doesn't show anything to the customer.  The same is true if you use white.

 

So I went "Well, if you really want to use OSCommerce - now is the time to see just how hard it is going to be to modify the software," and I began looking for where this is done.

 

I finally found what I was looking for in the catalog\includes\modules directory.  The script is the product_listing.php script.  If you go to the WHILE statement at line 94 you will see after that line that there is the following command:

$rows++;

If you put in the following commands:

if( $rows % 2 < 1 ){ $class = 'even'; }
            else { $class = 'odd'; }

Then you now have a way to alternate the color of the text for the links.  You then need to go down to lines 108-117 and modify the link's ending from:

'">'

to be:

'" class="' . $class . '">'

This will insert the even/odd class names into the "<a href=...>" statements that are generated.

 

The only thing left to do is to modify the stylesheet.css found in catalog directory.  Just insert:

A.even    { color: #000000; }
A.odd    { color: #ffffff; }

And that's it! :)

 

I tried just setting the product text color but since these are links - that doesn't work.  Here is what I tried:

.productListTable tr:nth-child(odd) td{
  background-color: #000000;
    color: #ffffff;
}

.productListTable tr:nth-child(even) td{
  background-color: #ecf6fc;
    color: #000000;
}

The above did nothing at all except for plain text.  The links just ignored it.  Thus the a.odd and a.even entries.

 

I hope this helps someone so they don't pull their hair out trying to figure this out.

 

Mark

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...