View Single Post
  #1  
Old 03-14-2003, 03:04 AM
 
funkydunk funkydunk is offline
 

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

Default Number of Products per Row changeable in admin

Cos I'm in a good mood today, a little mod to give and option in admin to specify the number of products per row that are displayed.

SQL to insert:

Code:
INSERT into `xcart_config` VALUES ('products_per_row','Product per row','2','General','66','text')
New customer/main/products.tpl template
(Note that this includes the add to cart button)

Code:
{* $Id: products.tpl,v 1.21 2002/11/19 12:57:48 alfiya Exp $ and amended further by funkydunk.net*} <table border=0 width=100% cellspacing=0 cellpadding=0> {section name=product loop=$products} {if $smarty.section.product.index is div by $config.General.products_per_row} <tr valign="top"> {/if} <td valign="top"> <table width=100% border=0 cellpadding=3 cellspacing=0> <tr> <td width=100 rowspan="2" align=left 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=100 product=$products[product].product}</a> </td> <td valign=top width=90%> {$products[product].product|escape}</font> <font class="ProductDetails"> {$products[product].descr|truncate:300:"...":true} </font> {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/(1-(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=ProductPrice>{$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}{if $config.General.use_vat eq "Y"}, including VAT {$products[product].vat}%{/if} {else} <font class=ProductPrice>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td> </tr> <tr> <td valign=top> <table width="80" border="0" cellspacing="0" cellpadding="2"> <tr valign="top"> <td><a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{include file="buttons/details.tpl"}</a></td> <td><form name=orderform_{%product.index%} method=post action="cart.php?mode=add"> <a href="javascript: document.orderform_{%product.index%}.submit()"> {include file="buttons/add_to_cart.tpl"}</a> <input type=hidden name=amount value=1> <input type=hidden name=mode value=add> <input type=hidden name=productid value="{$products[product].productid}"> <input type=hidden name=cat value="{$smarty.get.cat}"> <input type=hidden name=page value="{$smarty.get.page}"> </form></td> </tr> </table></td> </tr> </table> </td> {/section} </tr> </table>

You will then have an option in admin to specify the number of products per row that you want displayed. Obviously you will encounter problems with more than 3 in a row if you are using a three column layout for the shop.

Enjoy.
__________________
ex x-cart guru
Reply With Quote