rega Posted August 14, 2006 Share Posted August 14, 2006 I had a question about using a default value in the subdirectory field, in this case "products/" It's a simple change. Up at the top of categories.php in the configuration section just predefine the value of $image_subdirectory like so: // ---------- Configure Image Path Tool Features Below ---------- // define('USE_REG_GLOBALS_PATCH', 'false'); // Use the register globals fix define('USE_PHP5_MKDIR', 'false'); // Use the php5 mkdir function, set to false if you need to use chmod after creating directories define('SHOW_DIR_CHECKBOX', 'true'); // Allow users to create new directories define('USE_UNIX_SLASHES', 'true'); // Use / slashes for php4 mkdir. Set to false for Windows $image_subdirectory = 'products/'; // set default subdirectory // ----------------------- End Configure ----------------------- // Then that subdirectory will appear by default in the field and you can choose to use it, backspace through it or add to it. I tested this to set a default subdirect 'products' it is not work. The default subsirect will appear in the field but when you add a sub subdirect after that (like products/cats) and clike preview then update the image file will be save to products folder but not cats folder! Did I set something wrong or it's a bug? Quote Link to comment Share on other sites More sharing options...
frenchflies Posted September 1, 2006 Share Posted September 1, 2006 (edited) I'm getting this error message: Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid/gid is 143653/143653 is not allowed to access .../catalog/images/products/bags/fabrics owned by uid/gid 398/398 in .../admin/includes/classes/upload.php on line 91 Please help!! Edited September 1, 2006 by frenchflies Quote Link to comment Share on other sites More sharing options...
frenchflies Posted September 1, 2006 Share Posted September 1, 2006 never mind, I fixed it! great contrib! Quote Link to comment Share on other sites More sharing options...
frenchflies Posted September 2, 2006 Share Posted September 2, 2006 is this possible to get this work with more_pics? both cont. will modify the same function in admin/categories.php ... http://www.oscommerce.com/community/contri...earch,more+pics Quote Link to comment Share on other sites More sharing options...
handiangler Posted September 3, 2006 Share Posted September 3, 2006 Modify New Product page to support image directories------------------------------------------------------------ This is a simple modification to /admin/categories.php It adds a new field to the new product page named: Image Subdir. (images/...): just above the Product Image: field There is also a very minor change to /admin/includes/languages/english/categories.php. It adds only one line to define a new field name. This keeps the language defines stucture consistent with osC standards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this field you can add the path to your image location, ie: /pets, pets/dogs, pets/dogs/brown and so on. Add the path in that field, browse to to the correct image on your pc and the file will be uploaded to the correct directory and the image file name in the database will indicate the correct location, ie: /pets/kitty.jpg. The operations are identical to using the standard categories.php but with the addition of image paths. Delete a product and the corresponding image is deleted. The directories must exist on the server, it will not create them and they must be writable. If they can not be found or or not writable the standard osC error checking will give you a warning. You'll have to know/remember the directory names (sticky notes are good). It's based on the 051113 update version of osC MS2 so it incorporates all current updates. The changes are fairly simple and most users are using the stock categories.php file so this can just be used in its place. There is one simple change to admin/includes/languages/categories.php to add the name for the field in keeping with osC language conventions. I've only tested this on Unix/Linux systems but from my understanding it should be cross platform (it uses forward slashes in php for the subdirectory pointing). The installation instructions are in the install document. I just tried to install your script and can not find in my version of oscommerce update osC MS2 build 051113 in the file categories.php "define('TEXT_IMAGE_DIRECTORY" . I'm just NEW to this ecommerce stuff. I don't see a /admin directory but I do have /control directory. Are they the same? Thank U... Doug Quote Link to comment Share on other sites More sharing options...
Guest Posted September 6, 2006 Share Posted September 6, 2006 Great contribution! I am a photographer, and being able to have subdirectories in my images file is going to be an absolute joy! I installed and tested it today, and it works perfectly! Quote Link to comment Share on other sites More sharing options...
drakky Posted October 11, 2006 Share Posted October 11, 2006 That's much more reasonable than a drop down menu. A drop down menu would be best implemented using values stored in the database and I purposely avoided any database changes because it makes the contribution needlessly complex and harder to install. It also would be non trival since each entry would have to be tested to make sure that it didn't already exist. Who knows how many or what names people will dream up? You can use the category names but replace spaces with underscores. You should never put spaces in directory names or file names. It's as simple as something like this: $image_subdirectory = str_replace(" ","_",$category_name); // replace space with _ If you check a few posts up there's a simple change so that the value of $image_subdirectory is remembered for the duration of the session. That makes the job much easier. Hi , I'm not real sure why the drop down idea is a bad one? It's what they do in zen cart and it works well , having to type directories in is certainly an extremely bad idea unless you are creating the directory initially , after that you should be able to select the folder on the page not have to type it. If you have 20 new products all in different categories a drop down to insert the pics into the correct directory is a good idea to my way of thinking. Quote Link to comment Share on other sites More sharing options...
w0w Posted November 12, 2006 Share Posted November 12, 2006 hi AlanR, i have ultrapics and i need your contribution (images subdirectory). But i have a problem. if i install your contribution, i have delete code of ultra pics.. The problem is in admin/categories.php How to solve this problem? Is very difficult for me sorry for my english is very bad... help me please.... Quote Link to comment Share on other sites More sharing options...
w0w Posted November 13, 2006 Share Posted November 13, 2006 help me please!!! Quote Link to comment Share on other sites More sharing options...
ihbergin Posted November 16, 2006 Share Posted November 16, 2006 Hi Alan, it's a very good contribution if you have lots of images - in my case it's well over 2000. I've installed it and it has worked great until I started with the subcategories under a different category. To use images located in images/furniture works fine, I just type furniture/ in the subdirectories box. But when I'm trying to use images located in images/electric and type electric/ in the subdirectories box I just get "Error. File upload not saved" The images are all uploaded to their directories which have permission 776 = rwxrwx.. What can I do to make your contribution work with all my 39 image subdirectories not only furniture/ ?????????? /Helena Quote Link to comment Share on other sites More sharing options...
Guest Posted December 2, 2006 Share Posted December 2, 2006 How would I get this to work with Easy Populate? Quote Link to comment Share on other sites More sharing options...
TheExterminator Posted December 11, 2006 Share Posted December 11, 2006 (edited) This code will make is to work with MoPics 6 I will upload a zip fil to the Contributions. Chance the code in "admin/categories.php" (This work 100% on a Unix-Freebsd) // EOF: More Pics 6 // copy image only if modified // ************************* Image path modification starts below ************************* if (USE_REG_GLOBALS_PATCH == 'true') { link_post_variable('image_subdirectory'); // function included in the Register Globals Patch - functions/general.php link_post_variable('new_dir'); // function included in the Register Globals Patch - in functions/general.php } // Here we strip away any extra slashes the user may add to the subdirectory field and make sure there is a final /. $image_subdirectory = preg_replace('/\\\/', '/', $image_subdirectory); // in case someone mistakenly uses backward slashes, flip 'em around if ($image_subdirectory == '/') { ($image_subdirectory = ''); // in case the user mistakenly entered only a single / } if ($image_subdirectory != '') { // we want to add a path $image_subdirectory = preg_replace('/\/\/+/', '/', $image_subdirectory); // change any multiple slashes to a single / if (strpos($image_subdirectory, '/') === 0) { $image_subdirectory = substr($image_subdirectory, 1); // strip any leading slash } if (strrpos($image_subdirectory, '/') != (strlen($image_subdirectory) -1)) { $image_subdirectory = ($image_subdirectory . '/'); // add one slash at the end if there wasn't one. } } // End corrections of any user errors // Create directory if requested (Box Checked, $new_dir == 'on) if ($new_dir == 'on') { if (USE_UNIX_SLASHES == 'true') { $working_directory = DIR_FS_CATALOG_IMAGES . $image_subdirectory; if (USE_PHP5_MKDIR == 'true') { if (!is_dir($working_directory)) { mkdir($working_directory, 0777, 1); // chmod($working_directory, 0777); // Change to suit server needs, depending on directory owner } } else { // php4 mkdir recursion do { $dir = $working_directory; while (!@mkdir($dir,0777)) { $dir = dirname($dir); if ($dir == '/' || is_dir($dir)) break; } // chmod($dir, 0777); // Change to suit server needs, depending on directory owner } while ($dir != $working_directory); } } else { // End unix mkdir routine // Windows mkdir routine start $working_directory = DIR_FS_CATALOG_IMAGES . preg_replace('/\//', '\\', $image_subdirectory); // replaces forward slashes with backwards ones if (USE_PHP5_MKDIR == 'true') { if (!is_dir($working_directory)) { mkdir($working_directory, 0777, 1); // the 0777 chmod arg. has no effect under Windows, left in for consistency } } else { // php4 mkdir recursion do { $dir = $working_directory; while (!@mkdir($dir)) { $dir = dirname($dir); if ($dir == '\\' || is_dir($dir)) break; } } while ($dir != $working_directory); } } // End Windows mkdir routine } $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; $products_image_name = $image_subdirectory . $products_image_name; // ***** Prepend subdirectory to filename } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } // BOF: More Pics 6 // copy subimage1 only if modified $products_subimage1 = new upload('products_subimage1'); $products_subimage1->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage1->parse() && $products_subimage1->save()) { $products_subimage1_name = $products_subimage1->filename; $products_subimage1_name = $image_subdirectory . $products_subimage1_name; // ***** Prepend subdirectory to filename } else { $products_subimage1_name = (isset($HTTP_POST_VARS['products_previous_subimage1']) ? $HTTP_POST_VARS['products_previous_subimage1'] : ''); } // copy subimage2 only if modified $products_subimage2 = new upload('products_subimage2'); $products_subimage2->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage2->parse() && $products_subimage2->save()) { $products_subimage2_name = $products_subimage2->filename; $products_subimage2_name = $image_subdirectory . $products_subimage2_name; // ***** Prepend subdirectory to filename } else { $products_subimage2_name = (isset($HTTP_POST_VARS['products_previous_subimage2']) ? $HTTP_POST_VARS['products_previous_subimage2'] : ''); } // copy subimage3 only if modified $products_subimage3 = new upload('products_subimage3'); $products_subimage3->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage3->parse() && $products_subimage3->save()) { $products_subimage3_name = $products_subimage3->filename; $products_subimage3_name = $image_subdirectory . $products_subimage3_name; // ***** Prepend subdirectory to filename } else { $products_subimage3_name = (isset($HTTP_POST_VARS['products_previous_subimage3']) ? $HTTP_POST_VARS['products_previous_subimage3'] : ''); } // copy subimage4 only if modified $products_subimage4 = new upload('products_subimage4'); $products_subimage4->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage4->parse() && $products_subimage4->save()) { $products_subimage4_name = $products_subimage4->filename; $products_subimage4_name = $image_subdirectory . $products_subimage4_name; // ***** Prepend subdirectory to filename } else { $products_subimage4_name = (isset($HTTP_POST_VARS['products_previous_subimage4']) ? $HTTP_POST_VARS['products_previous_subimage4'] : ''); } // copy subimage5 only if modified $products_subimage5 = new upload('products_subimage5'); $products_subimage5->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage5->parse() && $products_subimage5->save()) { $products_subimage5_name = $products_subimage5->filename; $products_subimage5_name = $image_subdirectory . $products_subimage5_name; // ***** Prepend subdirectory to filename } else { $products_subimage5_name = (isset($HTTP_POST_VARS['products_previous_subimage5']) ? $HTTP_POST_VARS['products_previous_subimage5'] : ''); } // copy subimage6 only if modified $products_subimage6 = new upload('products_subimage6'); $products_subimage6->set_destination(DIR_FS_CATALOG_IMAGES . $image_subdirectory ); // ***** append server image subdirectory if ($products_subimage6->parse() && $products_subimage6->save()) { $products_subimage6_name = $products_subimage6->filename; $products_subimage6_name = $image_subdirectory . $products_subimage6_name; // ***** Prepend subdirectory to filename } else { $products_subimage6_name = (isset($HTTP_POST_VARS['products_previous_subimage6']) ? $HTTP_POST_VARS['products_previous_subimage6'] : ''); } // EOF: More Pics 6 break; } } // check if the catalog image directory exists Edited December 11, 2006 by TheExterminator Quote Link to comment Share on other sites More sharing options...
TheExterminator Posted December 11, 2006 Share Posted December 11, 2006 This code will make is to work with MoPics 6 You can download it here : http://www.oscommerce.com/community/contributions,3873 Chance the code in "admin/categories.php" (This work 100% on a Unix-Freebsd) Quote Link to comment Share on other sites More sharing options...
teraknor Posted December 26, 2006 Share Posted December 26, 2006 Having an error pop up when I select "update". This only happens when I have changed the config files for this mod (when I put the original files back the error goes away): Warning: Cannot modify header information - headers already sent by (output started at /home/mythgame/public_html/shop/admin/includes/languages/english/categories.php:1) in /home/mythgame/public_html/shop/admin/includes/functions/general.php on line 18 Any ideas as to what is going on? Quote Link to comment Share on other sites More sharing options...
c-m Posted February 1, 2007 Share Posted February 1, 2007 where is this contribution, I can't see a link to download it? I have modified files already so I basically just need the few lines of code and a bit of direction as to where to insert them. Quote Link to comment Share on other sites More sharing options...
c-m Posted February 1, 2007 Share Posted February 1, 2007 sorted now, thanks Quote Link to comment Share on other sites More sharing options...
awarner20 Posted February 15, 2007 Share Posted February 15, 2007 How would I get this to work with Easy Populate? Any word on installing this with Easy Populate? I'm very interested in this! Thanks, Adam Quote We see our customers as invited guests to a party, and we are the hosts. It's our job every day to make every important aspect of the customer experience a little bit better. - Jeff Bezos Link to comment Share on other sites More sharing options...
varanus9 Posted February 15, 2007 Share Posted February 15, 2007 Hi All, I have this contribution installed - it works great except for one thing...I am not getting any images to show up on the admin side. My store looks fine, all the images show up, but nothing in admin when I am looking at a product, or when I am looking at a category and the selected product is in the box to the right. It shows the image name, and has a space below it (bigger space than when there is no third, fourth image etc.) I have this contrib along with More Pics 6 (I checked and double-checked the code that came with this and used the "Install with More Pics 6" file to make the changes). I also went through the More Pics 6 again to make sure that was all correct - I am also using HTC 2.6, Product Extra Fields, and On-The-Fly Thumbnailer on this site. Any idea what could be causing my problem? I assume I must have something wrong in /admin/categories.php but I can't find where it is...I'd appreciate if anyone has any insight into this. Regards, Varanus9 Quote Link to comment Share on other sites More sharing options...
awarner20 Posted March 18, 2007 Share Posted March 18, 2007 sorted now, thanks Anybody using this with EasyPopulate? I'd REALLY like to know...:) Quote We see our customers as invited guests to a party, and we are the hosts. It's our job every day to make every important aspect of the customer experience a little bit better. - Jeff Bezos Link to comment Share on other sites More sharing options...
RBA Posted June 22, 2007 Share Posted June 22, 2007 Great Contribution :thumbsup: When I upload images into the sub directories they are put in the correct folder but the product info and image do not appear in admin in any categories. Before I installed subdirectories I had also installed Featured_Products_v4.3.4 which worked with categories until I installed the subdirectories. Now the products and images in subcatagories only show in the featured products admin section. Any help or ideas where I can look? RBA Quote Link to comment Share on other sites More sharing options...
jhande Posted August 11, 2007 Share Posted August 11, 2007 Just on the chance that their might be some support for this contribution still... :-" Is it possible to make this work with the big image contribution? I really would like to categorize my hundreds, if not thousands, of images. :'( Quote - :: Jim :: - - My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 - Link to comment Share on other sites More sharing options...
leveera Posted September 30, 2008 Share Posted September 30, 2008 Lets continue I use the contribution for RC1 but it needs modification to be compatable and functional. RC1 can work with register_globals off without any mods but the contribution use register globals fix for 2.2MS2. This is only for register_globals OFF on your server open admin/includes/functions/general.php add to the end of the file just before ?> //image_subdirectories function link_post_variable($var_name) { // Map global to POST variable if (isset($_POST[$var_name])) { $GLOBALS[$var_name] =& $_POST[$var_name]; } } set in admin/categories.php define('USE_REG_GLOBALS_PATCH', 'true'); // Use the register globals fix Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted November 14, 2008 Share Posted November 14, 2008 I installed it and get the error : Fatal error: Call to undefined function: link_post_variable() in /home/content/z/b/a/zbatson/html/klickshopping.co.uk/bin/categories.php on line 370 Does anyone have this function and know where to put it? It doesn't seem to be installed or available in my OsCommerce framework :( Quote Link to comment Share on other sites More sharing options...
lindsayanng Posted December 22, 2008 Share Posted December 22, 2008 i am curious.. I know this might be reaching, but i was wondering if there was a way that the path could be autofilled based on the category name? it would just make everything SOOO much easier. I have NO IDEA if that is possible or not, but just thinking of a way to make adding products easier. This is a great contribution and has REALLY REALLY helped me a TON since i have a photography site and thousands of images in that one folder. It was getting impossible to open the folder from my file manager.. its a LIFE saver!! This way, when you open to create a new product, that field will already say images/categoryname/ Quote A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!! Link to comment Share on other sites More sharing options...
homedecor Posted January 20, 2009 Share Posted January 20, 2009 I am wondering the same thing. Is it possible to make this a drop down list? I already have the 21 subdirectories and difficult to remember them all. It would make it a lot faster if this was possible. Even if it was coded into the categories.php and people could change the values themselves if they wanted to. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.