Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding ADDITIONAL additional images!!!


betty

Recommended Posts

Posted

Hi there,

 

I installed the additional images contribution a while ago. This produces a new table (additional_images) with a medium_images field in it. However, i'd like to try and add a big_images field too.

 

However, I'm not quite sure what i need to put in a certain section of admin/categories.php in order to add and delete the images. At the moment I've got:

 

case 'add_images':
       $products_id = $HTTP_GET_VARS['pID'];
       $add_images_error = true;
 
       if ($medium_images = new upload('medium_images', DIR_FS_CATALOG_IMAGES)) {
         $add_images_error = false;
         $sql_data_array = array('products_id' => tep_db_prepare_input($products_id),
                                 'images_description' => tep_db_prepare_input($HTTP_POST_VARS['images_description']),
                                 'medium_images' => tep_db_prepare_input($medium_images->filename));
         
 if ($big_images = new upload('big_images', DIR_FS_CATALOG_IMAGES)) {
         $add_images_error = false;
         $sql_data_array = array('products_id' => tep_db_prepare_input($products_id),
                                 'images_description' => tep_db_prepare_input($HTTP_POST_VARS['images_description']),
                                 'big_images' => tep_db_prepare_input($big_images->filename));   	 
    	 
    	 
    	 
         
         $sql_data_array = array_merge($sql_data_array, $add_data_array);
       }

       if ($add_images_error == false) {
         tep_db_perform(TABLE_ADDITIONAL_IMAGES, $sql_data_array);
       } else {
         $messageStack->add_session(ERROR_ADDITIONAL_IMAGE_IS_EMPTY, 'error');
       }
       tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
       break;
 
 
     case 'del_images':
       $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
       if ( ($HTTP_GET_VARS['pID']) && (is_array($HTTP_POST_VARS['additional_images_id'])) ) {                       
         $additional_images_id[] = tep_db_prepare_input($HTTP_POST_VARS['additional_images_id']);
         for ($i=0; $i<sizeof($additional_images_id); $i++) {

           $delimg_query = tep_db_query("select medium_images, big_images from " . TABLE_ADDITIONAL_IMAGES . " where additional_images_id = '" . tep_db_input($additional_images_id[$i]) . "'");
           $delimg = tep_db_fetch_array($delimg_query);
	 
           if (tep_not_null($delimg['medium_images']) && file_exists(DIR_FS_CATALOG_IMAGES.$delimg['medium_images']) )
               if (!unlink (DIR_FS_CATALOG_IMAGES.$delimg['medium_images']))
                  $messageStack->add_session(ERROR_DEL_IMG_XTRA.$delimg['medium_images'], 'error');
               else
                  $messageStack->add_session(SUCCESS_DEL_IMG_XTRA.$delimg['medium_images'], 'success');
      
         if (tep_not_null($delimg['big_images']) && file_exists(DIR_FS_CATALOG_IMAGES.$delimg['big_images']) )
               if (!unlink (DIR_FS_CATALOG_IMAGES.$delimg['big_images']))
                  $messageStack->add_session(ERROR_DEL_IMG_XTRA.$delimg['big_images'], 'error');
               else
                  $messageStack->add_session(SUCCESS_DEL_IMG_XTRA.$delimg['big_images'], 'success');
      
      
           tep_db_query("delete from " . TABLE_ADDITIONAL_IMAGES . " where additional_images_id = '" . tep_db_input($additional_images_id[$i]) . "'");
         }
       }
       tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
       break;

 

 

but this just produces a parse error. (When I comment out the sections that refer to big_images everything works ok, only i obviously can't add any big images).

 

I'm sure I'm doing something obviously very wrong, as i know effectively nothing about php and have just been guessing.

 

If anyone can spot the errors in the above chunk of code i'd be very grateful!!!!

 

Betty

Posted

why reinvent the wheel? there are many good contributions dealing with multiple images for osCommerce.

Posted

Hiya,

 

Well, i've just been having a bit of trouble, as I've tried installing 3 different contributions that ended up not doing what i wanted them to (ie. they don't let you decide where each extra image gets positioned on the page - they just lump them all in as extra images and display them in a row). however, i'm just trying the small, med and large cont. now so we'll see. Ideally i'd like to have 4 different named images for each product, and say image 1 always appear in the top corner of the product description, image 2 under the name, image 3 to the left, image 4 is the pop up etc etc... i'll let you know how i get on with the cont. i'm using now anyway...

 

Thanks!

 

Betty

Posted

all the contributions will be as you described, it is up to you to realign the tables to suit your needs, of where you want the images to appear. on one of mine i have 14 images, 7 small and 7 large.

Archived

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

×
×
  • Create New...