Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

i need help to display my pictures


paulchen2005

Recommended Posts

Hi,

 

i have install more pics 6 1 v1.2 and Categories and Products Images Folder Tree V 1.2

 

this code will save the 1. image in new folder (bsp. images/games/pic1.jpg)

 

	  case 'new_product_preview':
	$products_image = new upload('products_image');
	$prod_path = $HTTP_GET_VARS['cPath'];
	$lchar = strrpos($prod_path, '_');
	if ($lchar + 1 == 1) {
	$lachar = 0;
	} else {
	$lachar = $lchar + 1;
	}
	$prod_path_id = substr($prod_path, $lachar);
	$prod_folder = tep_output_generated_category_path_fs($prod_path_id);
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . $prod_folder);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {
$products_image_name2 = $HTTP_POST_VARS['products_previous_image'];
	}

 

and this code will show the image in admin menue:

 

$contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_image);

 

 

this code will save the subimage in new folder (bsp. images/games/subpic1.jpg)

 

		$products_subimage1 = new upload('products_subimage1');
	$prod_path = $HTTP_GET_VARS['cPath'];
	$lchar = strrpos($prod_path, '_');
	if ($lchar + 1 == 1) {
	$lachar = 0;
	} else {
	$lachar = $lchar + 1;
	}
	$prod_path_id = substr($prod_path, $lachar);
	$prod_folder = tep_output_generated_category_path_fs($prod_path_id);
	$products_subimage1->set_destination(DIR_FS_CATALOG_IMAGES . $prod_folder);
	if ($products_subimage1->parse() && $products_subimage1->save()) {
	  $products_subimage1_name = $products_subimage1->filename;
	} else {
	  $products_subimage1_name = $HTTP_POST_VARS['products_previous_subimage1'];
	}

 

but this code (to show the subimage) search the image in wrong ordner (bsp.images/subpic1.jpg)

 

and the picture is not represented in admin the menu.

 

		   $contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_subimage1, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_subimage1);

 

the codes are identically,

 

what can i do that the code search the image in correct folder ?

 

 

i think that this code save the folder not correct

 

$pInfo->products_subimage1

 

or $pInfo will not saved, what can i do ?

 

 

thank you very much

Paul

 

 

p.s.: my english is not very good, sorry for that... ;)

Link to comment
Share on other sites

Hi,

 

first i install the contrib Categories and Products Images Folder Tree V 1.2, and the image was save in new folder,

 

this is the installation guide

 

 

INSTALLATION

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

1. Using your mysql client, run these two queries (also in queries.sql):

ALTER TABLE categories CHANGE categories_image categories_image VARCHAR( 120 ) DEFAULT NULL;

ALTER TABLE products CHANGE products_image products_image VARCHAR( 120 ) DEFAULT NULL;

 

2. Only 2 files to change

 

/admin/categories.php

/admin/includes/functions/general.php

 

admin/categories.php

Around Line 57 find:
	  tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
	}

	$languages = tep_get_languages();

change to:
	  tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
	}
// images categories
	if ($action == 'update_category') {
	$old_dir_name = DIR_FS_CATALOG_IMAGES . tep_output_generated_category_path_fs($categories_id);
	}
// images categories eof
	$languages = tep_get_languages();


Around line 78 find:
		tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
	  } elseif ($action == 'update_category') {
		tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  }
	}

	if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
	  tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
	}

change to:
		tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
	  } elseif ($action == 'update_category') {
		tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  }
	}
// images categories
	  $dir_to_make = DIR_FS_CATALOG_IMAGES . tep_output_generated_category_path_fs($categories_id);
	  if (is_dir($dir_to_make) == false) {
		if ($action == 'insert_category') {
		mkdir($dir_to_make,0755);
		chmod($dir_to_make,0777);
		} elseif ($action == 'update_category') {
		rename($old_dir_name, $dir_to_make);
		$db_folder = tep_output_generated_category_path_fs($categories_id);
			$products_renamed_query = tep_db_query("update products p, products_to_categories pc set p.products_image = concat('".$db_folder."', (substring_index(p.products_image, '/', -1))) where pc.products_id = p.products_id and pc.categories_id = '" . (int)$categories_id . "'");
			$categories_renamed_query = tep_db_query("update categories set categories_image = concat('".$db_folder."', (substring_index(categories_image, '/', -1))) where categories_id = '" . (int)$categories_id . "'");
		}
	  }

	if ($categories_image = new upload('categories_image', $dir_to_make)) {
	  $db_image_file_name = tep_output_generated_category_path_fs($categories_id) . $categories_image->filename;
	  tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($db_image_file_name) . "' where categories_id = '" . (int)$categories_id . "'");
	}
// images categories eof 


Around line 241 find:
							  'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));

	  if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
		$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
	  }

change to:
							  'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));

	  if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
// images categories
		$sql_data_array['products_image'] = tep_output_generated_category_path_fs($current_category_id) . tep_db_prepare_input($HTTP_POST_VARS['products_image']);
// eof images categories
	  }


around line 335 find:
  case 'new_product_preview':
// copy image only if modified
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {


change to:
  case 'new_product_preview':
// copy image only if modified
	$products_image = new upload('products_image');
// images categories
	$prod_path = $HTTP_GET_VARS['cPath'];
	$lchar = strrpos($prod_path, '_');
	if ($lchar + 1 == 1) {
	$lachar = 0;
	} else {
	$lachar = $lchar + 1;
	}
	$prod_path_id = substr($prod_path, $lachar);
	$prod_folder = tep_output_generated_category_path_fs($prod_path_id);
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES . $prod_folder);
// eof images categories
	if ($products_image->parse() && $products_image->save()) {



admin/includes/functions/general.php
add the following at the end of the file before the closing ?>

// images categories
 function tep_output_generated_category_path_fs($id, $from = 'category') {
$calculated_category_path_string = '';
$calculated_category_path = tep_generate_category_path($id, $from);
for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
	  $ii = ($n - 1) - $i;
  for ($j=0, $k=sizeof($calculated_category_path[$ii]); $j<$k; $j++) {
	  $jj = ($k - 1) - $j;
	$dir_path = ereg_replace("[^a-z0-9._]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($calculated_category_path[$ii][$jj]['text']))));
	$calculated_category_string .= $dir_path . '/';		
  }
}
return $calculated_category_string;
 }
// eof images categories

 

 

after that i install more pics 6 v1.2, with a little change from this code:

 

		$products_subimage1 = new upload('products_subimage1');
	$products_subimage1->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_subimage1->parse() && $products_subimage1->save()) {
	  $products_subimage1_name = $products_subimage1->filename;
	} else {
	  $products_subimage1_name = (isset($HTTP_POST_VARS['products_previous_subimage1']) ? $HTTP_POST_VARS['products_previous_subimage1'] : '');
	}

 

in

 

		$products_subimage1 = new upload('products_subimage1');
	$prod_path = $HTTP_GET_VARS['cPath'];
	$lchar = strrpos($prod_path, '_');
	if ($lchar + 1 == 1) {
	$lachar = 0;
	} else {
	$lachar = $lchar + 1;
	}
	$prod_path_id = substr($prod_path, $lachar);
	$prod_folder = tep_output_generated_category_path_fs($prod_path_id);
	$products_subimage1->set_destination(DIR_FS_CATALOG_IMAGES . $prod_folder);
	if ($products_subimage1->parse() && $products_subimage1->save()) {
	  $products_subimage1_name = $products_subimage1->filename;
	} else {
	  $products_subimage1_name = (isset($HTTP_POST_VARS['products_previous_subimage1']) ? $HTTP_POST_VARS['products_previous_subimage1'] : '');
	}

 

 

all images (inkl. subimages) will now save in new folder but it does not show the subimages because it search in image/ and not in new folder image/games/

 

What can i do that the programm search the image in the new folder ???

 

please, i need help to find the error

 

thank you

Link to comment
Share on other sites

Hi,

 

i have it !!! it works perfect !!!

 

i add in categories.php under

$products_subimage1_name = $products_subimage1->filename;

 

this code:

$products_subimage1_name = tep_output_generated_category_path_fs($prod_path_id) . $products_subimage1_name;

 

now will the subimage save in new folder and display !!!

 

 

thank you very much !!! :D

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...