Quote:
Originally Posted by RobinThor
Hi I'm a new user to X-Cart, but I'll like to know how is it possible to have a product listing of the category at a detailed product page?
This is something like what I'm referring to : http://www.ahavaus.com/site/body_handcream.html
I'm not sure if I'm doing this right, but I think this would mean that I have to edit home.tpl to include the codes from products_t.tpl right? But I'm having a problem because home.tpl will know recognise the $product array variable from products.tpl or product_t.tpl.
Any help on this would be greatly appreciated!! Thanks a lot for your time!!
|
For version 4.1.9, I would have done so:
In the file "product.php" insert the following lines (before - "# Assign the current location line"):
PHP Code:
$allproduct = array();
$allproduct = func_query ("SELECT * FROM $sql_tbl[products], $sql_tbl[products_categories] WHERE $sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products].forsale='Y' $avail AND $sql_tbl[products_categories].categoryid='$cat'");
$smarty->assign("allproduct", $allproduct);
In the end file "skin1\customer\main\product.tpl" insert the following lines:
PHP Code:
<br>
{capture name=dialog}
{assign var="count_per_row" value=3}
<table border=0 width=100%>
{math equation="floor(100/x)" x=$count_per_row assign="width"}
{section loop=$allproduct name=ind}
{if %ind.index% is div by $count_per_row}
<tr>
{assign var="cell_counter" value=0}
{/if}
{math equation="x+1" x=$cell_counter assign="cell_counter" }
<td valign=top align=center width={$width}%>
<table border=0>
<tr>
<td align=center>
{include file="product_thumbnail.tpl" productid=$allproduct[ind].productid image_x=$allproduct[ind].tmbn_x|default:$config.Appearance.thumbnail_width image_y=$allproduct[ind].tmbn_y product=$allproduct[ind].product tmbn_url=$allproduct[ind].tmbn_url}
</td>
</tr>
<tr>
<td>
<a href="product.php?productid={$allproduct[ind].productid}&cat={$cat}" class="ProductTitle">{$allproduct[ind].product}</a>
</td>
</tr>
</table>
</td>
{capture name=prod_index}
{math equation="index+x+1" index=%ind.index% x=$count_per_row}
{/capture}
{if $smarty.capture.prod_index is div by $count_per_row}
</tr>
{/if}
{/section}
{if $cell_counter lt $count_per_row}
{section name=rest_cells loop=$count_per_row start=$cell_counter}
<td class="SectionBox"> </td>
{/section}
{/if}
</tr>
</table>
{/capture}
{include file="dialog.tpl" title="All products" content=$smarty.capture.dialog extra='width="100%"'}
Result:
{assign var="count_per_row" value=3} - Specifies the number of products displayed in a row.