Thread: What's new mod
View Single Post
  #9  
Old 03-28-2005, 11:37 PM
 
alkhashrami alkhashrami is offline
 

Newbie
  
Join Date: Jan 2005
Location: Abha, Saudi Arabia
Posts: 5
 

Default

Hi everybody ,

i tried to modify the this mod to work with my x-cart version and skin,
inspite i'm not a php expert but i depend on comparing similar files and do needed changes then testing on the site.

After 2 days i think that i solve it and this is the mod after modifications:

First, create a PHP file called newest.php that contains the following code:

Code:
<?php require "./auth.php"; require $xcart_dir."/include/categories.php"; // 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(func_get_langvar_by_name("lbl_what_is_new"),""); // give the product array to smarty to make it available sitewide. $smarty->assign("main","newest"); $smarty->assign("newproducts",$products); $smarty->assign("location",$location); $smarty->assign("wn","$wn"); func_display("customer/home.tpl", $smarty); ?>


Next, you'll need a template called customer/main/newest.tpl that contains the following code:

Code:
{capture name=dialog} {if $newproducts ne ""} {$lng.txt_last_added_products} {$smarty.get.wn} {if $smarty.get.wn > 1} {$lng.lbl_days}{else}{$lng.lbl_day}{/if}. {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} {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_added_products|substitute:"XX":$smarty.get.wn} {if $smarty.get.wn > 1} {$lng.lbl_days}{else}{$lng.lbl_day}{/if}. {/if} {/capture} {include file="dialog.tpl" title=$lng.lbl_new_products content=$smarty.capture.dialog extra="width=100%"}


Then edit customer/home_main.tpl to include this code:

Code:
{elseif $wn ne ""} {include file="customer/main/newest.tpl"}


Then, add these lang variables to the database (SQL)

Code:
INSERT INTO xcart_languages VALUES ('US','New products','lbl_new_products','New products','Labels'); INSERT INTO xcart_languages VALUES ('US','These are the products we have added in the last','txt_last_added_products','These are the products we have added in the last','Text'); INSERT INTO xcart_languages VALUES ('US','We are sorry, there are no new added products in the last {{XX}}','txt_no_added_products','We are sorry, there are no new added products in the last {{XX}}','Text'); INSERT INTO xcart_languages VALUES ('US','day','lbl_day','day','Labels');


Finally, you can call this mod through a link e.g:


"wn" indicats the number of days , wn=10 i.e. 10 days


I hope this will be good, and correct me if there is any mistake

thanks for all of you.
__________________
X-Cart Gold 4.0.17 (X-AOM, X-FancyCat, FasionMosaic skin)
Operating System Linux
Apache version 1.3.34 (Unix)
PHP version 4.4.1
MySQL version 4.1.13
Reply With Quote