View Single Post
  #2  
Old 04-02-2008, 12:24 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: How to list all products in specific category in a box on the homepage?

For version 4.1.9, I would have done so:

In the file "home.php" insert the following lines (before - "# Assign Smarty variables and show template"):

PHP Code:
if ((empty($cat))&&(empty($products)))
{
//number spec. cat :)))
    
$spec_cat 105
    
$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='$spec_cat'");
    
$smarty->assign("allproduct"$allproduct);  


In the end file "skin1\customer\main\welcome.tpl" insert the following lines:
PHP Code:
{include file="customer/main/specat.tpl"

Create file "customer/main/specat.tpl", so the following code:
PHP Code:
<br>
{
capture name=dialog}
{
assign var="count_per_row" value=2}
<
table border=0 width=100%>
{
math equation="floor(100/x)" x=$count_per_row assign="width"}
{
section loop=$allproduct name=ind}

{if %
ind.indexis 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}&amp;cat={$cat}class="ProductTitle">{$allproduct[ind].product}</a>
        </
td>
    </
tr>
</
table>

</
td>

{
capture name=prod_index}
    {
math equation="index+x+1" index=%ind.indexx=$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">&nbsp;</td>
    {/
section}
    {/if}
</
tr>
</
table>


{/
capture}
{include 
file="dialog.tpl" title="Cool products... or..." content=$smarty.capture.dialog extra='width="100%"'
Reply With Quote