X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   how to get 4 products a row on products.tpl? (https://forum.x-cart.com/showthread.php?t=39197)

MOC 04-19-2008 03:34 PM

how to get 4 products a row on products.tpl?
 
hi there,
i wanna display 4 products a row on products.tpl. (VERSION: 4.1.9)

i used this code, but it doesn't work for me. anyone who can tell me whats wrong with it?

Code:

<DIV class=product_records_container style="MARGIN-BOTTOM: 2px; BORDER-BOTTOM: #cccccc 1px dotted">
<TABLE cellSpacing=0 cellPadding=0 width=585 border=0>
  <TBODY>
  {section name=product loop=$products}
{assign var="discount" value=0}
{if %product.index% is div by 4}
<tr>
{/if}
  <TR>
    <TD>
      <TABLE id=ctl00_cpContentArea_dlProductRecords style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 border=0>
        <TBODY>
<tr>
 
          <TD vAlign=top>
            <DIV class=prod_box>
            <A href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_page}">
            {include file="product_thumbnail.tpl" productid=$products[product].productid image_x=130 image_y=130 product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
            {if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{/if}
            <IMG alt="" src="feature_exclusive.gif">
            <P><SPAN class=prodname>{$products[product].product}</SPAN></P></A>
            <P class=shortdescription>{$products[product].descr}</P>
            <P class=instock>--extrafield-shipping--</P><IMG src="star50.gif">
            <P class=prodprice>Our Price: {include file="currency.tpl" value=$products[product].price} ({include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price})</P></DIV></TD>
</tr>
 
        </TBODY></TABLE></TD></TR>{/section}</TBODY></TABLE></DIV>


kube 04-19-2008 03:56 PM

Re: how to get 4 products a row on products.tpl?
 
I know this isn't directly answering your question but what about...

In admin > General Setting > Appearance Options...
admin/configuration.php?option=Appearance

Change "Display products list in multiple columns (1-3) (leave empty to use standard format):", to 4

Then in products.tpl locate...
Code:

{if $usertype eq "C" and $config.Appearance.products_per_row ne "" and $config.Appearance.products_per_row gt 0 and $config.Appearance.products_per_row lt 4 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")}

and change the part $config.Appearance.products_per_row lt 4 to...

$config.Appearance.products_per_row lt 5

Hope this helps.

MOC 04-19-2008 04:43 PM

Re: how to get 4 products a row on products.tpl?
 
would work normally, but i need it hardcoded
and besides if i use it, i need to change the template and regardless if i try my code above or i try to add the products_t.tpl code to my code, the products aren't in a row anymore

kube 04-19-2008 05:18 PM

Re: how to get 4 products a row on products.tpl?
 
ok understandable, then how about trying...

Code:

<DIV class=product_records_container style="MARGIN-BOTTOM: 2px; BORDER-BOTTOM: #cccccc 1px dotted">
<TABLE cellSpacing=0 cellPadding=0 width=585 border=0>
<TBODY>
<tr>
{section name=product loop=$products}
{assign var="discount" value=0}
<TD>
<TABLE id=ctl00_cpContentArea_dlProductRecords style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top>
<DIV class=prod_box>
<A href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_page}">
{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=130 image_y=130 product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{/if}
<IMG alt="" src="feature_exclusive.gif">
<P><SPAN class=prodname>{$products[product].product}</SPAN></P></A>
<P class=shortdescription>{$products[product].descr}</P>
<P class=instock>--extrafield-shipping--</P><IMG src="star50.gif">
<P class=prodprice>Our Price: {include file="currency.tpl" value=$products[product].price} ({include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price})</P></DIV></TD>
</TR>
</TBODY>
</TABLE>
</TD>
       
{if ($smarty.section.product.iteration is div by 4) and not ($smarty.section.product.last)}</TR><TR>{/if}
                       
{/section}
</tr>
</TBODY>
</TABLE>
</DIV>


Hope this helps.

MOC 04-19-2008 05:28 PM

Re: how to get 4 products a row on products.tpl?
 
Thanks Kube,
working great. thanks thanks thanks SASKIA

kube 04-19-2008 05:53 PM

Re: how to get 4 products a row on products.tpl?
 
Hi again MOC I just cleaned up the code for you. As my app was coming out with all sorts of validation errors. Becareful with using a css id more than once on the same page (for example, id="ctl00_cpContentArea_dlProductRecords")

Code:

<div class="product_records_container" style="margin-bottom: 2px; border-bottom: #cccccc 1px dotted;">
<table cellspacing="0" cellpadding="0" width="585" border="0">
<tbody>
<tr>
{section name=product loop=$products}
{assign var="discount" value=0}
<td>
<table id="ctl00_cpContentArea_dlProductRecords" style="border-collapse: collapse;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top">
<div class="prod_box">
<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_page}">
{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=130 image_y=130 product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
{if $active_modules.special_offers ne "" and $products[product].have_offers}
{include file="modules/special_offers/customer/product_offer_thumb.tpl" product=$products[product]}
{/if}
<img alt="" src="feature_exclusive.gif" />
<p><span class="prodname">{$products[product].product}</span></p>
<p class="shortdescription">{$products[product].descr}</p>
<p class="instock">--extrafield-shipping--<img src="star50.gif" alt="" /></p>
<p class="prodprice">Our Price: {include file="currency.tpl" value=$products[product].price} ({include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price})</p></div></td>
</tr>
</tbody>
</table>
</td>
       
{if ($smarty.section.product.iteration is div by 4) and not ($smarty.section.product.last)}</tr><tr>{/if}
                       
{/section}
</tr>
</tbody>
</table>
</div>


Just in case it helps, no ideas. I'm bored - I know ;D

merbay 04-26-2008 06:23 AM

Re: how to get 4 products a row on products.tpl?
 
Hi, I made the changes per post #2 and it worked perfectly for me and I am happy. Some don't line up, but that is a factor of the title and can be fixed-- had the same problem when I had 3 across. My question is, must I have things hardcoded, or am I ok this way? Thanks for your help!

kube 04-26-2008 07:04 AM

Re: how to get 4 products a row on products.tpl?
 
Although I'm not 100% sure, I would say that to get more than 4 or more products per row would involve some level of hard coding considering the tpl looks for less-than-4.

The only other area I think it affects would be the featured products and I can't see it affecting invoices. However, there might be a few mods out there which require it.

merbay 04-26-2008 08:23 AM

Re: how to get 4 products a row on products.tpl?
 
I'm sorry to be such a pain, but I don't know where to put the coding in #6. I've looked in products.tpl and I don't see anything-- (also, I don't know if I'm replacing or adding)

I really like 4 across, so could you pls. give me more direction! Thanks.

kube 04-26-2008 08:39 AM

Re: how to get 4 products a row on products.tpl?
 
#6 contains code that is specific to MOC's website such as images and id/classes which you will not have and makes it confusing to control. Plus, there's more hard coding which is not necessary.

In the products.tpl or products_t.tpl, (dependent on what you have chosen as products per row) you would swap the whole section {section name=product loop=$products}bla bla{/section} with the code from #6

davidsaldana 12-15-2008 08:28 PM

Re: how to get 4 products a row on products.tpl?
 
I just went straight into the database and changed it to 4, and then changed products.tpl to less than 5. worked like a charm.

cbostard 01-04-2009 10:46 AM

Re: how to get 4 products a row on products.tpl?
 
how did you change the code in database? where to find file?
im using version 4.1.11

pfarcus 01-06-2009 01:43 PM

Re: how to get 4 products a row on products.tpl?
 
Hi,

I put the code from #6 replacing this: {section name=product loop=$products}bla bla{/section} but nothing happened, I'm not getting an error but its still 3 products per column. (or row) Is it because I am using version 4.2?

thx for your help.

pfarcus 01-16-2009 09:28 AM

Re: how to get 4 products a row on products.tpl?
 
Is this thread dead? Anyone ever get it to work in 4.1.11?

cbostard 01-18-2009 02:22 PM

Re: how to get 4 products a row on products.tpl?
 
i tried to combine post #6 and products_t.tpl and put it in products.tpl , im on version 4.1.11 and got it to work pretty good but it needs some product name and sku realigning I will paste code below and if anyone can help refine this please add toit in here

Quote:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div class="product_records_container" style="margin-bottom: 2px; border #474747 ">
<table cellspacing="0" cellpadding="0" width="620" border="5">
<tbody>
<tr>
<td>
<table width="100%" cellpadding="5" cellspacing="1">
{math equation="floor(100/x)" x=$config.Appearance.products_per_row assign="width"}
{section name=product loop=$products}
{assign var="discount" value=0}
<td>
<table id="ctl00_cpContentArea_dlProductRecords" style="border-collapse: collapse;" cellspacing="1px" cellpadding="3px">
<tbody>
<tr>
<td valign="top">
<div class="prod_box">
<a href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}" class="ProductTitle">{$products[product].product}</a><br />
{if $config.Appearance.display_productcode_in_list eq "Y" and $products[product].productcode ne ""}
{$lng.lbl_sku}: {$products[product].productcode}<br />
{/if}
<table cellpadding="3" cellspacing="0" width="100%">
<a href="product.php?productid={$products[product].productid}&amp;cat={$cat}&amp;page={$navigation_p age}">
{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=130 image_y=130 product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
{if $active_modules.Special_Offers ne "" and $products[product].use_special_price ne ""}
{include file="modules/Special_Offers/customer/product_special_price.tpl" product=$products[product]}
{/if}
<p <font class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].taxed_price}</font><br /><font class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</font>{if $discount gt 0}{if $config.General.alter_currency_symbol ne ""},{/if} {$lng.lbl_save_price} {$discount}%{/if}
{if $products[product].taxes}<br />{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes is_subtax=true}{/if}
</p>
</div></td>
</tr>
{if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"}
{include file="customer/main/buy_now.tpl" product=$products[product]}
{/if}
</tbody>
</table>
</td>

{if ($smarty.section.product.iteration is div by 4) and not ($smarty.section.product.last)}</tr><tr>{/if}

{/section}
{if $cell_counter lt $config.Appearance.products_per_row}
{section name=rest_cells loop=$config.Appearance.products_per_row start=$cell_counter}
<td class="SectionBox"> </td>
{/section}
</tr>
{/if}
</table>
</td>
</tr>
</table>
{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y' && $products_has_fclasses && $js_enabled}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}

pfarcus 01-18-2009 03:05 PM

Re: how to get 4 products a row on products.tpl?
 
cool, hey could you dumb it down a bit for me? Where would I paste it and would I paste the whole thing? (i'm still a copy paster)

thx a lot!

cbostard 01-18-2009 03:09 PM

Re: how to get 4 products a row on products.tpl?
 
copy and paste the entire thing thus replacing everything in products.tpl but make a back up copy somewhere on your local computor

this script basically is the new products.tpl located in Skin1/customer/main/products.tpl

pfarcus 01-18-2009 04:55 PM

Re: how to get 4 products a row on products.tpl?
 
dang, I did that and nothing seems to have happened, still 3 products per row. (tried entering 4 into the option box too)

?
Thx

pfarcus 01-19-2009 05:34 PM

Re: how to get 4 products a row on products.tpl?
 
Hey you were right, I was in skin1/main, i didn't realize there were more than 1 products.tpl, thanks! (its skin1/customer/main/products.tpl)

It works! I changed it to 5 per row too. The product name is bumping the top of the thumbnail on some, I can try and mess with that I guess.

Thanks again!

spence88mph 01-20-2009 12:34 PM

Re: how to get 4 products a row on products.tpl?
 
Has anyone got this to work on 4.2, the product.tpl is different, instead of a value of 4 it has &&.

pfarcus 03-21-2009 02:22 PM

Re: how to get 4 products a row on products.tpl?
 
Hi,

I bought a pure css skin and now I'm kind of lost as to how to do this. Can anyone understand my products.tpl now? How can I do 5 products in a row? thanks!

{* $Id: products.tpl,v 1.1.2.31 2008/04/17 05:46:15 max Exp $ *}


{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y' && $products_has_fclasses}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{include file="modules/Feature_Comparison/products_check_js.tpl"}
{/if}

{if $usertype eq "C" and $config.Appearance.products_per_row ne "" and $config.Appearance.products_per_row gt 0 and $config.Appearance.products_per_row lt 4 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")}
{include file="customer/main/products_t.tpl" products=$products}
{else}
{if $products}
{section name=product loop=$products}
{capture name=dialog}
{assign var="discount" value=0}
<div class="products_container">{* Container *}
<div class="products_left_col">{* Left Column *}
<a href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}{if $featured eq 'Y'}&featured{/if}">{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$config.Appearance.thumbnail_width product=$products[product].product tmbn_url=$products[product].tmbn_url}</a>
{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{/if}

{** JB EgoodsLocalUpload *}
{if $products[product].esdlu_filetype ne ""}
{include file="customer/main/esdlu_filetypes.tpl" filetypeval=$products[product].esdlu_filetype}
{/if}
{** end JB EgoodsLocalUpload *}

<br />
<a href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}{if $featured eq 'Y'}&featured{/if}">{$lng.lbl_see_details}</a>
{if $active_modules.Feature_Comparison ne '' && $products[product].fclassid > 0 && $printable ne 'Y'}
<br />
{include file="modules/Feature_Comparison/compare_checkbox.tpl" id=$products[product].productid}
{/if}
</div>{* /Left Column *}
<div class="products_right_col">{* Right Column *}
<div>{$products[product].descr|truncate:300:"...":true}</div>
<br />
{if $config.Appearance.display_productcode_in_list eq "Y" and $products[product].productcode ne ""}
<label>{$lng.lbl_sku}</label>
<div class="right">{$products[product].productcode}</div>
<br class="clearboth" />
<!--[if IE 6]><br class="clearboth_ie" /><![endif]-->
{/if}
{if $products[product].product_type eq "C"}
{include file="buttons/details.tpl" href="product.php?productid=`$products[product].productid`&cat=`$cat`&page=`$navigation_page`"}
{else}
{if $active_modules.Subscriptions ne "" and ($products[product].catalogprice gt 0 or $products[product].sub_priceplan gt 0)}
{include file="modules/Subscriptions/subscription_info_inlist.tpl"}
{else}
{if ($config.General.unlimited_products ne "Y" && ($products[product].avail le 0 or $products[product].avail lt $products[product].min_amount) && $products[product].variantid) or ($products[product].taxed_price ne 0 or ($products[product].variantid && $products[product].variants_has_price) or ($active_modules.Special_Offers ne "" and $products[product].use_special_price ne ""))}
{if $products[product].taxed_price ne 0 or ($products[product].variantid && $products[product].variants_has_price)}
{if $products[product].list_price gt 0 and $products[product].taxed_price lt $products[product].list_price}
{math equation="100-(price/lprice)*100" price=$products[product].taxed_price lprice=$products[product].list_price format="%3.0f" assign=discount}
{if $discount gt 0}
<label>{$lng.lbl_market_price}</label>
<div class="right">{include file="currency.tpl" value=$products[product].list_price}</div>
<br class="clearboth" />
<!--[if IE 6]><br class="clearboth_ie" /><![endif]-->
{/if}
{/if}
<label>{$lng.lbl_our_price}</label>
<span class="product_price">{include file="currency.tpl" value=$products[product].taxed_price}{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].taxed_price}</span>{if $discount gt 0}{if $config.General.alter_currency_symbol ne ""},{/if} {$lng.lbl_save_price} {$discount}%{/if}
{if $products[product].taxes}
{include file="customer/main/taxed_price.tpl" taxes=$products[product].taxes is_subtax=true}
{/if}
{/if}

<br class="clearboth" />
<!--[if IE 6]><br class="clearboth_ie" /><![endif]-->
{if $active_modules.Special_Offers ne "" and $products[product].use_special_price ne ""}
{include file="modules/Special_Offers/customer/product_special_price.tpl" product=$products[product]}
{/if}
{else}
{$lng.lbl_enter_your_price}
{/if}
{/if}
{*** Uncomment it if you need 'Buy Now' button ***
{if $usertype eq "C" and $config.Appearance.buynow_button_enabled eq "Y"}
{include file="customer/main/buy_now.tpl" product=$products[product]}
{/if}
*** Uncomment it if you need 'Buy Now' button ***}
{/if}
</div>{* /Right Column *}
<br class="clearboth" />
</div>{* /Container *}
{/capture}
{include file="dialog.tpl" title=$products[product].product content=$smarty.capture.dialog extra='width="100%"'}
{/section}
{if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y' && $products_has_fclasses}
{include file="modules/Feature_Comparison/compare_selected_button.tpl" no_form=true}
{/if}
{else}
{capture name=dialog}
{$lng.txt_no_products_found}
{/capture}
{include file="dialog_blank.tpl" title=$lng.txt_no_products_found content=$smarty.capture.dialog extra='width="100%"'}
{/if}

{/if}


All times are GMT -8. The time now is 12:04 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.