Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Random Image Scripts

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #31  
Old 10-15-2003, 03:04 PM
  august's Avatar 
august august is offline
 

Senior Member
  
Join Date: Jul 2003
Posts: 178
 

Default

If what you want is to show a random of all the products in your front page, then I recommend that you use funky "new products mod" is the same principle and can work for featured products. Just he need to do some adjustments.
Reply With Quote
  #32  
Old 11-20-2003, 10:34 PM
  leon's Avatar 
leon leon is offline
 

X-Wizard
  
Join Date: Mar 2003
Location: Costa Rica
Posts: 1,213
 

Default

Quote:
Originally Posted by august
If what you want is to show a random of all the products in your front page, then I recommend that you use funky "new products mod" is the same principle and can work for featured products. Just he need to do some adjustments.

So what would be the most updated (and workable) version for this mod ?
__________________
It doesn\'t matter what is done... it is how it is done.
=============================
XCart Version: 3.5.3 -> Dmcigars.com
XCart Version: 4.1.3....
Reply With Quote
  #33  
Old 11-21-2003, 03:22 AM
  august's Avatar 
august august is offline
 

Senior Member
  
Join Date: Jul 2003
Posts: 178
 

Default

If it does not work, he will make it work.
Reply With Quote
  #34  
Old 01-01-2004, 04:09 PM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

TelaFirma,

First I would like to thank you for your code. Next, I would like to request your assitance. By the way I'm using x-cart 3.5.x

I have made a slight change so that when implemented, the query will randomly select an image from the amongst thumbnail images as opposed to the detailed image as you originally coded. All seems to be fine, everytime I refresh the page a different product is referenced except that the thumbnail images themselves are not displayed, I get the default "No Image Available" image being shown. I believe the "Get thumbnail's URL" area is where the problem lies. I took the liberty to open up "featured_products.php" to see how it pulls back the thumnail's url. It does it like so:
Quote:
#
# Get thumbnail's URL (uses only if images stored in FS)
#
$f_products[$f_v]["tmbn_url"] = func_get_thumbnail_url($f_products[$f_v]["productid"]);

It appears to using the function: func_get_thumbnail_url. I have tried to use it as well with no success.

Here is the code I currently have for "random.php"(without func_get_thumbnail_url) :

Quote:
<?
// give it all available products to work with
// $image_id = func_query("SELECT productid FROM $sql_tbl[thumbnails]);

// 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[thumbnails] 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);
?>

Any assitance would be greatly appreciated. Anybody else with some ideas on this, please share your thoughts.

Thanks,

Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #35  
Old 01-02-2004, 11:46 AM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default

Help,

Anybody have any ideas on my previous question?


Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #36  
Old 01-06-2004, 11:21 AM
 
dealsondeals dealsondeals is offline
 

eXpert
  
Join Date: Dec 2002
Location: Dallas, Texas, USA
Posts: 231
 

Default In need of assitance............

Help,

I would like to request your assitance. By the way I'm using x-cart 3.5.x

I have made a slight change so that when implemented, the query will randomly select an image from the amongst thumbnail images as opposed to the detailed image as you originally coded. All seems to be fine, everytime I refresh the page a different product is referenced except that the thumbnail images themselves are not displayed, I get the default "No Image Available" image being shown. I believe the "Get thumbnail's URL" area is where the problem lies. I took the liberty to open up "featured_products.php" to see how it pulls back the thumnail's url. It does it like so:

Quote:
#
# Get thumbnail's URL (uses only if images stored in FS)
#
$f_products[$f_v]["tmbn_url"] = func_get_thumbnail_url($f_products[$f_v]["productid"]);

It appears to using the function: func_get_thumbnail_url. I have tried to use it as well with no success.

Here is the code I currently have for "random.php"(without func_get_thumbnail_url) :
Quote:
<?
// give it all available products to work with
// $image_id = func_query("SELECT productid FROM $sql_tbl[thumbnails]);

// 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[thumbnails] 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);
?>

Any assitance would be greatly appreciated.

Thanks,

Glen
__________________
Never understimate stupidity.
--------
X-Cart Version: 3.5.2
Hosting:mind-in-design.net
Configuration: Virtual Dedicated Server || Intel Pentium 4 2.4 GHZ CPU || 1024MB PC2100 DDR RAM || Linux || PHP 4.3.2 || MySQL server 4.0.14
Reply With Quote
  #37  
Old 01-06-2004, 01:23 PM
  august's Avatar 
august august is offline
 

Senior Member
  
Join Date: Jul 2003
Posts: 178
 

Default

Hi, I don't know much php but Iseen this done somewhere here in the forum. There is a routine done by Funkidunk, which take the latest product that you input and show it randomly everytime that you refresh the page (if that what I understand that you want to do) You can do a search in the forum or e-mail funki for the code, and he gladly will help you with this.
Reply With Quote
  #38  
Old 01-22-2004, 12:24 PM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

Sorry I have missed this post for so long... but here is what you should do to get it to work with thumbnails...

random.php should be:

Code:
<? $images = func_query("select * from $sql_tbl[thumbnails] 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"]["thumbnails_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"]); } } print_r ($images); $smarty->assign("images",$images); ?>


and randoms.tpl should be:

Code:
<a href=product.php?productid={$images[0].productid}> {if $images[0].tmbn_url} [img]{$images[0].tmbn_url}[/img] {else} [img]../product_image.php?imageid={$images[0].imageid}[/img] {/if} </a>

Basicaly all I changed was the database table that it was looking at, changed the config variable (to check where the thumbnails were stored) and changed the array variable used in the template.
Reply With Quote
  #39  
Old 09-25-2005, 10:42 AM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

Anyone have a working version for 4.0.14?
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
  #40  
Old 09-30-2005, 01:59 PM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

Anyone?
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:32 PM.

   

 
X-Cart forums © 2001-2020