From this post
Code:
this is the current sql not the new stuff. the new stuff will be more complex than this.
need to add this into customer/home.php
Code:
include "./random.php";
This will bring in a list of random products.
Then we need to create this random.php in customer/ and is based on reccomends.php
Code:
<?
// give it all available products to work with
$products_id = func_query("SELECT productid FROM $sql_tbl[products] WHERE forsale='Y' and avail>0");
// set the variables
$str = "";
$numberRandoms=10; // set this to how many you want to show
// the witchcraft
$query_condition = " AND (";
srand((double)microtime()*1000000);
$rnd = rand(0, count($products_id)-1);
$query_condition .= "productid='".$products_id[$rnd][productid]."'";
for($i = 0; $i < $numberRandoms - 1; $i++) {
$rnd = rand(0, count($products_id)-1);
if (!ereg("'".$products_id[$rnd][productid]."'", $query_condition)) {
$query_condition .= " OR productid='".$products_id[$rnd][productid]."'";
}
}
// finish off the query
$query_condition .= ")";
// runs the new random query against the database
$query = "SELECT * FROM $sql_tbl[products] WHERE forsale='Y' AND avail>0".$query_condition;
// give the product array to smarty to make it available sitewide.
$randoms = func_query($query);
$smarty->assign("randoms",$randoms);
?>
You will then need to include this in the home page by modifying the appropriate templates.
Where in the home.php code does the include string go, or should it be 'require' instead of 'include'?
Should the random.php file go into the customer/ directory, or customer/main/ ?
Thanx