Jump to content
Sign in to follow this  
equilla

[CONTRIB] Options as Images for MS2

Recommended Posts

Hi Zillah,

 

glad you like the contribution.

 

I coded this one as I knew I would be having to bring my wife's store across onto an MS2 build some time in the near future. As she sells wigs, she uses options as images a lot and I wanted something robust....

 

I have deliberately with this contrib stuck to doing just "what it says on the tin". There are a many other contribs that allow alternative management of attributes and I thought it best to leave well alone here.

 

Personally, I use the Improved Attributes Manager contrib that allows all required attributes to be applied to a product in one hit.

 

So, at this time I don't intend including anything like that in this contrib I'm afraid.

 

Regards,

 

 

 

Mark

Share this post


Link to post
Share on other sites

I've downloaded the module and get stuck on these lines:

 

"Add the following to /admin/includes/filenames.php:-"

 

Why don't I have this file and how do I make it work without it? I have a admin/file_manager.php. Is this what I'm looking for?

 

Be gentle with me, I'm new at this.

Share this post


Link to post
Share on other sites

Hi,

 

that's not the file you're after, but you're close...!

 

The file will be in a folder underneath that one called includes. If you don't have the file filenames.php it could be that you have a MS1 store. In this case the file to modify would be application_top.php. There are complete instructions for MS1 users in the readme for this contrib. You'll know when you have the correct file as there will be a whole lot of other statements that are similar in there:

 

define ('TABLE_SOMETHING_OR_OTHER', 'somefile.php');

......

......

 

Cheers,

 

 

 

Mark

Share this post


Link to post
Share on other sites

OK, well I figured out that little glitch. I put the info in a config.php that had alot of other "define" variables. That works now, I think.

 

Now I'm having trouble with this error message while trying to edit my attributes in "options as images".

 

"Warning: copy({personal path information deleted from here}/catalog/images/options/nylonneonpink.jpg): failed to open stream: Permission denied in {personal path information deleted from here}/admin/options_images.php on line 31

unable to copy /tmp/phpzoFB4B to location {personal path information deleted from here}/catalog/images/options/nylonneonpink.jpg"

 

I have the following permissions set up for that dir (default):

drwxr-xr-x

 

I FTP'd all the files that I needed to that dir, I just need to tell the prog that "neon pink" in "nylonneonpink.jpg" etc.

Share this post


Link to post
Share on other sites

Thank you for the quick reply Mark. I made the changes you indicated and I'm still getting the error as indicated in my previous post.

 

How can I tell what version of the store I'm running and how can I update? I'm running several modules now and will I have to redo all of these?

 

Teri

Share this post


Link to post
Share on other sites

I have an idea. Is my login/password requirement blocking the files from uploading? I installed EZPopulate and there was an option in that module to input my login/password to upload the tab-delimited files.

 

Just at thought.

 

Teri

Share this post


Link to post
Share on other sites

Hi again,

 

you could try setting Chmod 777 on that folder.

 

Here's the way things should work:

 

1. The form you use to edit the options posts the file from your hard drive onto the server (the server determines where it puts the temporary copy of the uploaded file).

 

2. The script then copies the file from the temporary location into the correct place (images/options folder).

 

So, if it isn't a problem with being able to write to the images/options folder then it must be a problem of having permission to read the temporary file that is created by the webserver. This latter case is unlikely as the options as images script uses exactly the same technique as the script that uploads images when you list a new product in your store (I'm assuming that this part of things is working for you).

 

Easypopulate is shouldn't be a factor here by the way. I have this mod and easypopulate living happily side by side on one of my builds.

 

Regards,

 

 

 

Mark

Share this post


Link to post
Share on other sites

Hi,

 

I am getting this error when I run the mod.

Warning: Invalid argument supplied for foreach() in /www/r/rosevalley/htdocs/catalog/admin/options_images.php on line 40

 

Also the pictures upload as they should and are in the right spot, but they do not show in the admin or the catalog. The sql executed perfectly according to phpmyadmin. What could I be doing wrong???

 

 

Help!!

 

Thanks,

Mystic

-aka-

Kevin

 

http://www.rosevalleysoaps.com


Kevin Rosenthal

Share this post


Link to post
Share on other sites
Hi,

 

I am getting this error when I run the mod.

Warning: Invalid argument supplied for foreach() in /www/r/rosevalley/htdocs/catalog/admin/options_images.php on line 40

 

Also the pictures upload as they should and are in the right spot, but they do not show in the admin or the catalog. The sql executed perfectly according to phpmyadmin. What could I be doing wrong???

 

 

Help!!

 

Thanks,

Mystic

-aka-

Kevin

 

http://www.rosevalleysoaps.com

Sorry guys, It turned out I somehow CHMOD the image dir to the wrong number. :-( The Mod works GREAT!!!!

 

BRAVO

 

Kevin :rolleyes:


Kevin Rosenthal

Share this post


Link to post
Share on other sites

It's been a while since I've hacked at this but in studying the error message I'm getting, I notice there are two "//" in the directory path that it's trying to copy to. Could this be the problem and how do I solve it. Permissions are set up on all my dirs.

 

I've also ftp'd my color option jpgs, is there a way for me to get the prog to see these without uploading each jpg individually?

 

Here is the orig error message.

 

Warning: copy(/hsphere/local/home/naggnwit/domain.com//catalog/images/options/raspberry.jpg) [function.copy]: failed to create stream: Permission denied in /hsphere/local/home/naggnwit/domain.com/admin/options_images.php on line 31

unable to copy /tmp/phpsrN5fJ to location /hsphere/local/home/naggnwit/domain.com//catalog/images/options/raspberry.jpg

Share this post


Link to post
Share on other sites

Hi,

 

The line in admin/options_images.php that does the copy is this one:

 

copy($image_source , $image_destination) or die("unable to copy $image_source to location $image_destination");

 

with $image_destination being set up by an earlier line as follows:

 

$image_destination = DIR_FS_CATALOG_IMAGES . 'options/' . $filename;

 

That shouldn't result in a double slash before the "catalog" part of the path - if it does, you should check your configure.php in the admin/includes folder.

 

There is a slight error elsewhere in the file that has recently been brought to my attention on line 145:

 

<td class="dataTableContent" align="center"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . '/options/' . $products_options_values_thumbnail, $products_options_values_name, '50', '50') ?></td>

 

should be :

 

<td class="dataTableContent" align="center"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . 'options/' . $products_options_values_thumbnail, $products_options_values_name, '50', '50') ?></td>

 

This does result in a double slash in the path to the image displayed on screen in admin, but oddly does not seem to affect the correct operation of things.

 

I will issue an update once I have a few more improvements sorted. If anyone has anything else that they would like to see included in a future update, please let me know.

 

Cheers,

 

 

 

Mark

Share this post


Link to post
Share on other sites
That shouldn't result in a double slash before the "catalog" part of the path - if it does, you should check your configure.php in the admin/includes folder.

I found this error and corrected it.

 

There is a slight error elsewhere in the file that has recently been brought to my attention on line 145:

I also corrected this one.

 

These 2 things corrected the problem with the double slash and now the files will upload.

 

I'm still having a problem viewing the option thumbnails in admin. Any ideas?

 

Teri

Share this post


Link to post
Share on other sites

Great Contrib, Mark.

 

I had no problems installing it and I have it working right along with the Attribute Sets contrib. :)

 

I have been looking at the code for the options_images.php and the code in the shopping_cart.php file and I trying to figure out an easy way to show the selected Option's Image on the Cart page. I dont think it is possible but maybe I missed a part in the code. Any insight?

 

Another thing, when I click on an image (Pop up is on) the image pops up in a new window but I dont see the full image. Either the window is the correct size but the image is not directly on the top of the page (a space between the two) or the window is not set to open big enough. You can see an example on any of the test products @ http://www.anexclusivebeadshop.com

 

Thanks for the help.

 

Tracer


Lance Corporal in the United States Marine Corps

 

Head Support Admin: PNphpBBHacks

 

PNphpBB Support Team Member PNphpBB

Share this post


Link to post
Share on other sites

Hi,

 

I have installed the newest version of this mod and it works nice. I only have one problem. I can not delete an item from the Atttributes Images Manager. I hit the delete button and nothing seems to happen. The item is still there. :( Any ideas what I can be doing wrong?

 

Thanks,

Kevin


Kevin Rosenthal

Share this post


Link to post
Share on other sites
Hi,

 

I have installed the newest version of this mod and it works nice. I only have one problem. I can not delete an item from the Atttributes Images Manager. I hit the delete button and nothing seems to happen. The item is still there. :( Any ideas what I can be doing wrong?

 

Thanks,

Kevin

 

Sorry,

 

One more error.

 

When I deselect a attribute group to use images I get the error below. But once I select another page in the admin and come back to the Options as Images section, it shows that group deselected and no error. Any ideas?

 

Warning: Invalid argument supplied for foreach() in /home/rosevall/public_html/shop/admin/options_images.php on line 40

Kevin Rosenthal

Share this post


Link to post
Share on other sites
updates on this contribution would be nice.. im trying to get it to work but it doesnt show the images at all.

gtr_rider

 

check 2 things

 

Go to the configuration page of admin section.

 

Bottom link should be called

Options as Images.

 

On that page make sure "Click the images to enlarge" is set to true

 

THEN

under the catalog section

Find the link called

Options as images.

 

On the bottom of that page there are some check boxes to determine which options will show the images instead of a drop down box.

 

If it still doesn't work....

Check your CHMOD permissions on the

CATALOG/IMAGES/OPTIONS folder

make sure you have write permissions set to it.

Share this post


Link to post
Share on other sites

Looking for a fix to align the options better.

 

I've noticed that when you enable Options as Images, when you view a product that has options as images enabled the images of the options don't align in a very neat way.

 

Example can be found

Example 1

 

 

Example 2

 

Im gessing that the problem is it just lists the options without putting each one in its own table field.

 

Anyone know how to set this up in the fashion so the options are aligned neatly, while still keeping the option to choose how many options are listed per line?

 

Im guessing the problem lies within the following code.

 $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
?>
         <table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <?php  echo '<td class="main" colspan="2">' . TEXT_PRODUCT_OPTIONS . '<br>Please select your desired option using the buttons provided'; ?>
    	 <?php if (OPTIONS_IMAGES_CLICK_ENLARGE == 'true') echo '<br><b>CLICK THE IMAGES TO ENLARGE</b>';?>
    	 </td>
           </tr>
<?php
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_images_enabled from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.products_options_values_thumbnail, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
       while($products_options = tep_db_fetch_array($products_options_query)){ 
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'], 'thumbnail' => $products_options['products_options_values_thumbnail']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }
   
     if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }

?>

           <tr>
             <td class="main" valign="top"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

Edited by NCR2000

Share this post


Link to post
Share on other sites
gtr_rider

 

check 2 things

 

Go to the configuration page of admin section.

 

Bottom link should be called

Options as Images.

 

On that page make sure "Click the images to enlarge" is set to true

 

THEN

under the catalog section

Find the link called

Options as images.

 

On the bottom of that page there are some check boxes to determine which options will show the images instead of a drop down box.

 

If it still doesn't work....

Check your CHMOD permissions on the

CATALOG/IMAGES/OPTIONS folder

make sure you have write permissions set to it.

 

Thanks I hadnt realized that it wont show unless you set it as Click the image to enlarge. :lol:

Share this post


Link to post
Share on other sites
Thanks I hadnt realized that it wont show unless you set it as Click the image to enlarge.  :lol:

err I meant make sure

Use Images for product options is set to True...

 

Sorry bout that

Share this post


Link to post
Share on other sites

Ok, i was mistaken it doesnt work properly.. everything was set fine, and now it doesnt work anymore.. im also using a STS contribution if that would change anything.

Share this post


Link to post
Share on other sites

Anyone using this contribution with 'On the Fly' Auto Thumnailer or a similar contrib? I just tried to install On the Fly but it is 'breaking' my option images by messing up the src. With the option installed the src code for the options display comes out looking like this:

 

<td class="main"><table><tr><td><table cellspacing="1" cellpadding="0" border="0"><td align="center"><a href="java script:popupWindow('http://www.hulasupplycenter.com/catalog/options_images_popup.php?oID=2')"><img src="product_thumb.php?img=images/options/multiColor.jpg&w=80&h=22" width="80" height="22" border="0" alt="Multi" title="Multi"></a></td></tr><tr><td class="main" align="center">Multi</td></tr><tr><td align="center"><input type="radio" name ="id[1]" value="2" checked></td></tr></table></td><td><table cellspacing="1" cellpadding="0" border="0"><td align="center"><a href="java script:popupWindow('http://www.hulasupplycenter.com/catalog/options_images_popup.php?oID=1')"><img src="product_thumb.php?img=images/options/brown.jpg&w=80&h=28" width="80" height="28" border="0" alt="Brown" title="Brown"></a></td></tr><tr><td class="main" align="center">Brown</td></tr><tr><td align="center"><input type="radio" name ="id[1]" value="1" checked></td></tr></table></td></table> </td>

 

When it should look like this:

 

<td class="main"><table><tr><td><table cellspacing="1" cellpadding="0" border="0"><td align="center"><a href="java script:popupWindow('http://www.hulasupplycenter.com/catalog/options_images_popup.php?oID=2')"><img src="images/options/multiColor.jpg" border="0" alt="Multi" title=" Multi " width="80" height="80"></a></td></tr><tr><td class="main" align="center">Multi</td></tr><tr><td align="center"><input type="radio" name ="id[1]" value="2" checked></td></tr></table></td><td><table cellspacing="1" cellpadding="0" border="0"><td align="center"><a href="java script:popupWindow('http://www.hulasupplycenter.com/catalog/options_images_popup.php?oID=1')"><img src="images/options/brown.jpg" border="0" alt="Brown" title=" Brown " width="80" height="80"></a></td></tr><tr><td class="main" align="center">Brown</td></tr><tr><td align="center"><input type="radio" name ="id[1]" value="1" checked></td></tr></table></td></table> </td>

 

It is the edits to includes/functions/html_output.php that are causing it but I am not sure what I need to do to make these 2 get along.

 

--------------------------------------------------------------------

 

Regards to gtr_rider: Did you get it working? I am using STS as well, here is what I did to make it work for the site www.hulasupplycenter.com/catalog/.

 

includes/sts_product_info.php file:

approx line 64

find:

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");

 

directly above this line, ADD:

if (OPTIONS_AS_IMAGES_ENABLED == 'false'){

 

next, find:

$template['optionchoices'] .= tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . "<br>";

}

 

after this line, ADD:

//Options as Images. Add the curly bracket as shown on the next line

}

 

Next, in includes/sts_templates/[your template folder]/product_info.php.html

 

Where you want the options to display, ADD:

<?php

//Options as Images. This whole php clause needs to be added

if (OPTIONS_AS_IMAGES_ENABLED == 'true') include ('options_images.php');

?>

 

So that is what I did - if anyone has a better way I'm interested in knowing because this seems a little hinky.

 

Thanks!

Alane

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×