Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Alternate row colours

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 01-09-2003, 10:55 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default Alternate row colours

If you want the product list to show up in alternate colours this can be done by changing the customer/main/products.tpl template.

Change:
Code:
{* $Id: products.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *} {section name=product loop=$products} <table border=0 width=100%> <tr><td width=90 align=center valign=top> <a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=70 product=$products[product].product} { $lng.lbl_see_details }</a> </td> <td valign=top> {$products[product].product|escape}</font> <font class=TableCenterProductTitleOrange></font> <font size=1> {$products[product].descr|truncate:300:"...":true} </font> <hr size=1 noshade width=230 align=left> {if $active_modules.Subscriptions ne "" and $products[product].catalogprice} {include file="modules/Subscriptions/subscription_info_inlist.tpl"} {else} {if $products[product].price ne 0} {if $products[product].discount ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s>{math equation="(price/(100-discount))*100" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font> {/if} <font class=TableCenterProductTitleOrange>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if} {else} <font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td></tr> </table> {/section}
to
Code:
{* $Id: products.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *} {section name=product loop=$products} <table border=0 width=100%{if $smarty.section.product.index is div by 2} class="alternate1"{else} class="alternate2"{/if}> <tr><td width=90 align=center valign=top> <a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=70 product=$products[product].product} { $lng.lbl_see_details }</a> </td> <td valign=top> {$products[product].product|escape}</font> <font class=TableCenterProductTitleOrange></font> <font size=1> {$products[product].descr|truncate:300:"...":true} </font> <hr size=1 noshade width=230 align=left> {if $active_modules.Subscriptions ne "" and $products[product].catalogprice} {include file="modules/Subscriptions/subscription_info_inlist.tpl"} {else} {if $products[product].price ne 0} {if $products[product].discount ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s>{math equation="(price/(100-discount))*100" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font> {/if} <font class=TableCenterProductTitleOrange>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if} {else} <font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td></tr> </table> {/section}

Then set up two styles alternate1 and alternate2 in skin1.css like:
Code:
.alternate1{ BACKGROUND-COLOR: #FFFFCC; } .alternate2{ BACKGROUND-COLOR: #FFFF99; }
Obviously set up two colours that actually look good together
__________________
ex x-cart guru
Reply With Quote
  #2  
Old 01-10-2003, 12:55 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Niiice, think I'll have to use this
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 03-13-2003, 01:26 PM
 
cmolocznik cmolocznik is offline
 

Newbie
  
Join Date: Mar 2003
Posts: 2
 

Default

Smarty has a built in function for alternating row colors!

<tr bgcolor="{cycle values="#F3F3F3,#FFFFFF"}">

Code:
<table width="400"> {section name=ship_num loop=$shipping} <tr bgcolor="{cycle values="#F3F3F3,#FFFFFF"}"> <td><label> <input name="shippingid" type="radio" onSelect="" onClick="document.cartform.submit()" value="{$shipping[ship_num].shippingid}" {if $shipping[ship_num].shippingid eq $cart.shippingid}checked{/if}> {$shipping[ship_num].shipping|escape}</label><td align="right">{include file="currency.tpl" value=$cart.shipping_cost}</td></td> </tr> {/section} </table>
Reply With Quote
  #4  
Old 03-14-2003, 12:16 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Does it do alternative styles?
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 03-14-2003, 11:17 AM
 
cmolocznik cmolocznik is offline
 

Newbie
  
Join Date: Mar 2003
Posts: 2
 

Default

Yes it will!

<tr class="{cycle values="alternate1,alternate2"}">

http://smarty.php.net/manual/en/language.function.cycle.php
Reply With Quote
  #6  
Old 03-14-2003, 10:20 PM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default



must have missed that bit when I refer to smarty.php.net

Thanks for pointing it out.
__________________
ex x-cart guru
Reply With Quote
  #7  
Old 03-17-2003, 05:46 AM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

In fact you can specify as many colors to cycle through as you want (e.g. <tr class="{cycle values="alternate1,alternate2,alternate3,alternate X"}">). It's pretty sweet.
Reply With Quote
  #8  
Old 03-17-2003, 05:52 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

smarty is
__________________
ex x-cart guru
Reply With Quote
  #9  
Old 04-01-2003, 01:02 PM
 
John7 John7 is offline
 

Senior Member
  
Join Date: Jan 2003
Posts: 136
 

Default Like I said

Like I said usually somthing I want to is already asked and I can just find it here. Like this feature. Will try it now.

John
Reply With Quote
  #10  
Old 04-03-2003, 06:10 PM
 
John7 John7 is offline
 

Senior Member
  
Join Date: Jan 2003
Posts: 136
 

Default One Problem

One problem

How can I use this mod to change the way it displays the product description in the product.tpl.

I'd like one line to be one color and the next the other and visa versa.

Thanks
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:41 PM.

   

 
X-Cart forums © 2001-2020