DeadScary Posted February 7, 2007 Share Posted February 7, 2007 Hi folks I have a issue when editing the catagories. After doing my edit I click save and all seems to work fine. However if I had an image already assigned to that catagory it forgets the image and I get a message saying "Image dosen't exist". It's starting to annoy me as I don't want to have to upload the image everytime I edit the catagory. Please Help Link to comment Share on other sites More sharing options...
travtele615 Posted February 7, 2007 Share Posted February 7, 2007 Hi folks I have a issue when editing the catagories. After doing my edit I click save and all seems to work fine. However if I had an image already assigned to that catagory it forgets the image and I get a message saying "Image dosen't exist". It's starting to annoy me as I don't want to have to upload the image everytime I edit the catagory. Please Help Is it doing the same thing with Manufacturers images ? I just posted a topic because I'm trying to find a solution to this myself. http://www.oscommerce.com/forums/index.php?showtopic=249832 I'm hoping I've traced down the problem although I'm not sure I've got the experience to just whip out the solution. Travis Link to comment Share on other sites More sharing options...
DeadScary Posted February 8, 2007 Author Share Posted February 8, 2007 Yes it's the same thing. I know it's to do with when you update the cat/manafactuer it updates the table with a blank field. I don't know enough about the code to stop it though. anyone have any ideas? Link to comment Share on other sites More sharing options...
DeadScary Posted February 9, 2007 Author Share Posted February 9, 2007 Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me. Here is what I did. (remeber to backup your files before you try it) Open admin/categories.php Replace this code around line 80 - 82 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 . "'"); } With // If no image set allow upload and setting of new image if ($HTTP_POST_VARS['categories_image2'] == ''){ $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 . "'"); } //if image is set and image update is checked then upload new image if (($HTTP_POST_VARS['categories_image2'] != '') && ($HTTP_POST_VARS['newimage'] == 'Y')) { $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 . "'"); } Next after this line (around 905) $contents[] = array('text' => '<br>' . TEXT_EDIT_CATEGORIES_IMAGE . '<br>' . tep_draw_file_field('categories_image')); Add this $contents[] = array('text' => '<br>Update Image<br>' . tep_draw_checkbox_field('newimage', Y)); $contents[] = array('text' => tep_draw_hidden_field('categories_image2',$cInfo->categories_image)); In simple terms upload images as normal. You can now edit the category without loosing the image. If you wish to update the image just browse for it as normal and check the update image box. I'm sure there are neater ways of doing this but it's working and that's the main thing. Link to comment Share on other sites More sharing options...
travtele615 Posted February 14, 2007 Share Posted February 14, 2007 Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me. I'm sure there are neater ways of doing this but it's working and that's the main thing. Thanks for taking a look at this. I've been slammed to the wall on another project and this is the first chance I've had to check in on this in a week . Did you get a chance to look at the Manufacturers code at all? I'm going to give your code a try as I've got the same problems happening with my Cate. and Manu. admin areas. Thanks Again Travis Link to comment Share on other sites More sharing options...
DeadScary Posted February 15, 2007 Author Share Posted February 15, 2007 Thanks for taking a look at this. I've been slammed to the wall on another project and this is the first chance I've had to check in on this in a week . Did you get a chance to look at the Manufacturers code at all? I'm going to give your code a try as I've got the same problems happening with my Cate. and Manu. admin areas. Thanks Again Travis Haven't had a chance to have a look yet, not a high priorty for me on this project but will have a look when I get the chance Link to comment Share on other sites More sharing options...
DeadScary Posted February 16, 2007 Author Share Posted February 16, 2007 I used the Catagory Descriptions Mod today. Works well and also fixes the problem of disapearing images in the catagories edit. http://www.oscommerce.com/community/contri...ory+description Link to comment Share on other sites More sharing options...
travtele615 Posted February 22, 2007 Share Posted February 22, 2007 Ok I've fixed the categories so you can now edit them without having to upload the image each time. Just a couple of edits and it's working for me. I'm sure there are neater ways of doing this but it's working and that's the main thing. Just wanted to say a quick thanks. Your code fixed the problem Travis Link to comment Share on other sites More sharing options...
travtele615 Posted February 22, 2007 Share Posted February 22, 2007 find the same lines of code in admin/manufacturers.php as above for categories and your code works perfect there as well just change "categories" to "manufacturers" throughout near line 45-50 // If no image set allow upload and setting of new image if ($HTTP_POST_VARS['manufacturers_image2'] == ''){ $manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES); tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . tep_db_input($manufacturers_image->filename) . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } //if image is set and image update is checked then upload new image if (($HTTP_POST_VARS['manufacturers_image2'] != '') && ($HTTP_POST_VARS['newimage'] == 'Y')) { $manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES); tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . tep_db_input($manufacturers_image->filename) . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } near line 250ish $contents[] = array('text' => '<br>Update Image<br>' . tep_draw_checkbox_field('newimage', Y)); $contents[] = array('text' => tep_draw_hidden_field('manufacturers_image2',$mInfo->manufacturers_image)); Thanks again Travis Link to comment Share on other sites More sharing options...
hcamelion Posted July 24, 2007 Share Posted July 24, 2007 Here is a simpler fix: if($_FILES['manufacturers_image']['name'] != '') { if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) { tep_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } } You can do the same for catalog images. NY Web Development Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.