Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

can this be done?


ryanf

Recommended Posts

Hey, I was wondering if it is possible to search through a directory of images and return and display certain ones.

 

What I want to do is first take the image name of the current product being looked at, then strip the .jpg or .gif off and search for other images that start with the same string.

 

so if I have an image 1234.jpg it would look for all images that start with 1234 such as 1234_stuff 1234_otherstuff then display them on the product info page.

 

Any way I can do this?

 

I figure this would be better than having to use a contrib like ultrapics or mo pics then I wouldn't have to add all the images for every product, just make sure the image names have the same beginning. This also would effect contribs such as easy populate which is always good.

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

basically you are looking to do disk i/o, using *nix commands internally, or windows, and store things into an array, for matching then have to fo an fopen, etc.

Link to comment
Share on other sites

What I did is created a field in my products table called num_of_pics. When I add a new product I enter the number of pictures that I have for that product. When I create the pictures I give them the product number + the increment like this:

 

1234_1.jpg

1234_2.jpg

1234_3.jpg

1234_4.jpg

 

Then in my product_info I read num_of_pics from the products table which returns 4. I then have a for..loop which concatenates the product number + the increment and builds the filename and adds a link to my product page.

 

hth

I'd rather be flying!

Link to comment
Share on other sites

for my shops, i have alot of images that are the same model number, but for different stores

 

what i did was use ReaJpeg [from download.com] to add a suffix to all of them. like 1234X.jpg or 1234Y.jpg. You could also consider this a 1234 prefix to x.jpg and y.jpg. [for x store or y store]

 

Then, in windows search, i just looked for x or y and i would get all the products from the X store or Y store. This is helpful in the products database because you an search for anything like 1234* or *x to find exactly what you are looking to collect.

 

good luck,

 

brett

Link to comment
Share on other sites

Thanks for the replys guys.

 

Brett, I am not concerned about searching through my images on my machine but having php do it when the customers click on an object.

 

Mibble, are all those commands, that I can have php execute?

 

Bluepony, thats a good idea and I might try doing that but I was hoping that I wouldn't have to add anything to the products table that I have to add manually for each product, or also nothing that would effect easy populate or any other contribs.

 

What would be ideal is since if it happened everytime a customer clicked on a product, it would slow down the load, to have a new table that had two fields:

product_id and product_image. Then in the admin I could click a button and it would go through all my images and compare them to one another setting up relations. Since all my images are named the same as my product name, it would be able to find which ones go with which product.

 

Then when a customer clicks on a product, product_info will go to the new table to get all the images and display them.

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

When I add a new product I enter the number of pictures that I have for that product. When I create the pictures I give them the product number + the increment.

 

Then in my product_info I read num_of_pics from the products table which returns 4.  I then have a for..loop.

Blue Pony, can we see an example of this?

 

The only page you modified was product_info?

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

Hey everyone, I spent all day working on it and finally got it! Works just the way I wanted it to. This should save me tons of time by not having to add every picture is I have multiples. It even sets of the popup image since I have them set at different sizes.

 

If you want to see it in action here is a link to my only product so far:

16A11A

 

and here is a screen shot of the admin section:

imagefinder.gif

 

If anyone is interested, I will try to find time this weekend to make it into a contrib.

 

Next I want to modify the store so that I don't have to go through the process of adding any images. Right now i have to do it so that the images show up in the product displays. I think I don't have to change that much to get them working.

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...