View Single Post
  #7  
Old 04-21-2008, 07:21 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?

Quote:
Originally Posted by yamiya
Hi,

I love your code. But is there anyway to display the prices and SKU just as in Featured Product Box? Also how do I sort them according to Product Name?

Hope to get an answer for that.

For display the price.... Need make next change as in Featured Product Box (or subcategories):

in home.php change last code by:
PHP Code:
if ((empty($cat))&&(empty($products)))
{
    
//number spec. cat 
    
$spec_cat "3"
    
$old_search_data $search_data["products"];
    
$old_mode $mode;
    
$old_page $page;

    
$search_data["products"] = array();
    
$search_data["products"]["categoryid"] = $spec_cat;
    
$search_data["products"]["search_in_subcategories"] = "";
    
$search_data["products"]["category_main"] = "Y";
    
$search_data["products"]["category_extra"] = "Y";
    
$search_data["products"]["forsale"] = "Y";

// sort field and order by....
    
if(!isset($sort)) $sort "title";
    if(!isset(
$sort_direction))    $sort_direction 0;

    
$mode "search";

    include 
$xcart_dir."/include/search.php";

    
$smarty->assign("allproduct"$products);  

    
$search_data["products"] = $old_search_data;
    
x_session_save("search_data");
    
$mode $old_mode;
    
$page $old_page;
    unset(
$old_search_data$old_mode$old_page);



File "customer/main/specat.tpl" change by this 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>
    
    {if 
$config.Appearance.display_productcode_in_list eq "Y" and $$allproduct[ind].productcode ne ""}
    <
tr>
        <
td>
        {
$lng.lbl_sku}: {$allproduct[ind].productcode}
        </
td>
    </
tr>
    {/if}
    <
tr>
        <
td>
            {
assign var="discount" value=0}
            {if 
$allproduct[ind].list_price gt 0 and $allproduct[ind].taxed_price lt $allproduct[ind].list_price}
                {
math equation="100-(price/lprice)*100" price=$allproduct[ind].taxed_price lprice=$allproduct[ind].list_price format="%3.0f" assign=discount}
                    {if 
$discount gt 0}
                        <
font class="MarketPrice">{$lng.lbl_market_price}: <s>
                            {include 
file="currency.tpl" value=$allproduct[ind].list_price}
                        </
s></font><br />
                    {/if}
            {/if}

            {if 
$active_modules.Special_Offers ne "" and $allproduct[ind].use_special_price ne ""}
                <
s>
            {/if}

            <
font class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$allproduct[ind].taxed_price}</font><font class="MarketPrice">{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$allproduct[ind].taxed_price}</font>{if $discount gt 0}{if $config.General.alter_currency_symbol ne ""},{/if} {$lng.lbl_save_price} {$discount}%{/if}

            {if 
$active_modules.Special_Offers ne "" and $allproduct[ind].use_special_price ne ""}
                </
s>
            {/if}

            {if 
$allproduct[ind].taxes}
                <
br />
                <
div class="PListTaxBox">{include file="customer/main/taxed_price.tpl" taxes=$allproduct[ind].taxes}</div>
            {/if}

            {if 
$active_modules.Special_Offers ne "" and $allproduct[ind].use_special_price ne ""}
                {include 
file="modules/Special_Offers/customer/product_special_price.tpl" product=$allproduct[ind]}
            {/if}

        </
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%"'


PS. Not much has changed the way you get the list of products.
Reply With Quote