Here is one for you... It is a little more work, but is is nice
Make a new file in /skin1/customer/main/ named
randoms.tpl. In this file put:
Code:
<a href=product.php?productid={$images[0].productid}>
{if $images[image].tmbn_url}
[img]{$images[0].tmbn_url}[/img]
{else}
[img]../product_image.php?imageid={$images[0].imageid}[/img]
{/if}
</a>
Create a new file in /customer/ named
random.php. In this file put:
Code:
<?
// give it all available products to work with
// $image_id = func_query("SELECT imageid FROM $sql_tbl[images] WHERE avail='Y'");
// set the variables
// $str = "";
// $numberRandoms=1; // set this to how many you want to show
// srand((double)microtime()*1000000);
// $rnd = rand(0, count($image_id)-1);
$images = func_query("select * from $sql_tbl[images] ORDER BY RAND() limit 1");
if ($current_area != "C" && is_array($images)) {
foreach($images as $k=>$v) {
$images[$k]["type"] = (eregi("gif",$v["image_type"])?"GIF":(eregi("png",$v["image_type"])?"PNG":"JPG"));
}
}
#
# Get thumbnail's URL (uses only if images stored in FS)
#
if ($config["Images"]["det_images_location"] == "FS")
if ($current_area == "C" && is_array($images)) {
foreach($images as $k=>$v)
if (eregi("^(http|ftp)://", $v["image_path"]))
# image_path is an URL
$images[$k]["tmbn_url"] = $v["image_path"];
elseif (eregi($xcart_dir, $v["image_path"])) {
# image_path is an locally placed image
$images[$k]["tmbn_url"] = $http_location.ereg_replace($xcart_dir, "", $v["image_path"]);
}
}
$smarty->assign("images",$images);
?>
Next, insert this into your
welcome.tpl file:
Code:
{include file="customer/main/randoms.tpl"}
Next, in the
customer/home.php file look for
Code:
require "../include/categories.php";
and insert this line under it:
Code:
include "./random.php";
What this does is ger a list of all the Detail Images used for all your products. It then choses one at random and displays it, also linking it to the respective product page that it belongs to.
*This is for version 3.4.x and will work with inages stored in a File System or in the Database.[/code]