I've created a pretty simple "what's new" modification that someone might be interested in. It displays all the products that were created within a configurable number of days.
First, create a PHP file called newest.php that contains the following code:
Code:
<?
// set variables
$daterange = 60 * 60 * 24 * $wn; // days in unix time
$nowtime = time();
$oldtime = $nowtime - $daterange ;
$objects_per_page = $config["Appearance"]["products_per_page"];
// the database query
$search_data["products"] = array();
$search_data["products"]["forsale"] = "Y";
$from_tbl[$sql_tbl['featured_products']] = 0;
$search_condition = "DATE_SUB(CURDATE(),INTERVAL ". $wn . " DAY) <= from_unixtime(".add_date.") AND ";
$mode = "search";
include $xcart_dir."/include/search.php";
$location[]=array("What's New","");
// give the product array to smarty to make it available sitewide.
$smarty->assign("newproducts",$products);
$smarty->assign("location",$location);
$smarty->assign("navigation_script","home.php?wn=$wn");
?>
Then change home.php to include the following:
Code:
if (!empty($wn)) {
include "./newest.php";
$smarty->assign("wn","$wn");
}
I put that right after the Bestsellers code.
Next, you'll need a template called customer/main/newest.tpl
Code:
Visit this area of the store to see all the new items we've added in the last {$smarty.get.wn} days.
{if $mode eq "search"}
{if $total_items gt "1"}
{$lng.txt_N_results_found|substitute:"items":$total_items}
{$lng.txt_displaying_X_Y_results|substitute:"first_item":$first_item:"last_item":$last_item}
{elseif $total_items eq "0"}
{$lng.txt_N_results_found|substitute:"items":0}
{/if}
{/if}
{capture name=dialog}
{if $newproducts ne ""}
{if $total_pages gt 2}
{assign var="navpage" value=$navigation_page}
{/if}
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
{if $sort_fields}
{assign var=url value="home.php?wn="|cat:$smarty.get.wn|cat:"&"}
<TR>
<TD>{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url=$url}
</TD>
</TR>
{/if}
<TR>
<TD>
{include file="customer/main/navigation.tpl"}
{include file="customer/main/products.tpl" products=$newproducts}
{include file="customer/main/navigation.tpl"}
</TD>
</TR>
</TABLE>
{else}
{$lng.txt_no_new|substitute:"XX":$smarty.get.wn}
{/if}
{/capture}
{include file="dialog.tpl" title="New Products" content=$smarty.capture.dialog extra="width=100%"}
Then edit customer/home_main.tpl to include the previous template:
Code:
{elseif $main eq "subscriptions"}
{include file="modules/Subscriptions/subscriptions.tpl"}
{elseif $wn ne ""}
{include file="customer/main/newest.tpl"}
{elseif $main eq "catalog" and $current_category.category eq ""}
{include file="customer/main/welcome.tpl" f_products=$f_products}
Then I added a config table setting called TFTACustom.wndays, you can call it anything you'd like.
Assuming that you called it that, you can then add a link in the categories.tpl
This mod works as written with 4.0.7
Walt