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

HOW TO: show different images for listed/featured products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-17-2003, 11:43 AM
 
Mad Mad is offline
 

Advanced Member
  
Join Date: Jul 2003
Location: Brooklyn, NY
Posts: 60
 

Default HOW TO: show different images for listed/featured products

[edit] For a how-to see 3rd post [/edit]

Hi,
How hard would the following be?
The way it is now the featured product window takes my product images and sizes them down in the browser to 70x71. My images are rather detailed, so this process really make the images look pretty bad. I use the filesystem BTW, so it uses URL's for pictures. Now what I would like to do is have 2 images for everything. The normal image that shows in the product details is product.jpg, and for my featured products I would like x-cart to use product_f.jpg (for example, if it's easier this file could also be named to something else).

Anyone have any ideas on how I should should go at this?

Thanks in advance!
Reply With Quote
  #2  
Old 08-17-2003, 01:45 PM
 
Mad Mad is offline
 

Advanced Member
  
Join Date: Jul 2003
Location: Brooklyn, NY
Posts: 60
 

Default

Nevermind this was pretty easy after I looked into it further. If anyone wants to know how I did it let me know.
Reply With Quote
  #3  
Old 08-29-2003, 10:51 AM
 
John7 John7 is offline
 

Senior Member
  
Join Date: Jan 2003
Posts: 136
 

Default How did you do it?

How did you do it?

Thanks
Reply With Quote
  #4  
Old 08-30-2003, 07:46 AM
 
Mad Mad is offline
 

Advanced Member
  
Join Date: Jul 2003
Location: Brooklyn, NY
Posts: 60
 

Default

[EDIT] THERE IS A MUCH EASIER AND BETTER WAY POSTED BELOW! THIS ONE IS GOOD IF YOU WANT ALL THE PICTURES SEPERATED FROM EACH OTHER. [/EDIT]

Ok I used this method for both product listings (20x29 pics, example @ http://www.madtech.org/customer/home.php?cat=53) and featured products (70x70 pics, example @ http://www.madtech.org/customer/home.php?cat=103). This is a very dirty hack simply involving file names, it could probably be done better and more cleanly, but fuck it this works. This hack assumes you're using the filesystem to store pics. I won't provide any support for people who cant get it to work, I'm posting this and you can figure it out from there.

First edit your /include/func.php and add the following function at the bottom (anywhere actually). You will need to edit the home directory in the function below.
Code:
function func_get_thumbnail_name($productid) { global $config, $sql_tbl, $xcart_dir, $http_location; if ($config["Images"]["thumbnails_location"] == "FS") { $thumbnail_info = func_query_first("SELECT image_path, image_type FROM $sql_tbl[thumbnails] WHERE productid='$productid'"); if (eregi("^(http|ftp)://", $thumbnail_info["image_path"])) # image_path is an URL return $thumbnail_info["image_path"]; elseif (eregi($xcart_dir, $thumbnail_info["image_path"])) { # image_path is an locally placed image $url = ereg_replace("/home/madtech/public_html/files/", "", $thumbnail_info["image_path"]); return $url; } } return false; }

Now create a file called product_thumbnail_feat.tpl in /skin1/.

Code:
{if $config.Appearance.show_thumbnails eq "Y"} [img]{if $tmbn_name}{$http_location}/path/to/featured/files/{$tmbn_name|replace:[/img]{/if}

Now I don't remember what the original line was, but in /costumer/products_t.tpl basically where it calls for product_thumbnail.tpl replace that with the following. All that's changed is that it points to product_thumbnail_feat.tpl and passes a parameter that we created the function for earlier (tmbn_name=$products[product].tmbn_name).

Now you should be all set, simply get some application that will bath resize all your pics for you, and then rename all the files (there are also tools that will do this for you) to the following. If your original product pic is called example.jpg the new sized photo should be called example.jpg_f.jpg. So all this hack does is add a tag to a filename. If you want to to this to product listings thumnbails, just follow the above steps and instead create a file called product_thumnbail_list.tpl, make products.tpl call for _list.tpl and pass the tmbn_name parameter. That's it!

Good luck to everyone who will attempt this, if you come up with a cleaner hack share the wealth!

Enjoy the hack!
Reply With Quote
  #5  
Old 08-30-2003, 10:13 PM
 
Mad Mad is offline
 

Advanced Member
  
Join Date: Jul 2003
Location: Brooklyn, NY
Posts: 60
 

Default

OK here is the easier way. It's much faster to implement, but it assumes that all files (normal, featured & listed) are all in one directory, instead the above way allows you to have they sorted out in different directories. So here we go.

Create a file called /product_thumbnail_feat.tpl
Code:
{if $config.Appearance.show_thumbnails eq "Y"}[img]{if $tmbn_url}{$tmbn_url|replace:[/img]{/if}

Now all you have to do is look through /customer/main/products_t.tpl and replace the call for product_thumbnail.tpl to our newly created file. That's it! No extra functions to create or anything. I'm still using the original way because I have a lot of products and it's easier to have pics in different directories.

Again this will show the featured product images from example.jpg to example_f.jpg. Also it's best to have all files in one format, but if not creating a function that checks if a file is .gif or .jpg wouldn't be hard.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 12:09 PM.

   

 
X-Cart forums © 2001-2020