Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Categories and Products Images Folder Tree V 1.3


lildog

Recommended Posts

Categories and Products Images Folder Tree V 1.3

written by GottaLoveIT ([email protected])

for osCommerce 2.2MS2 (see included GPL license)

 

This contribution will automatically make folders under the /catalog/images folder that will match the categories tree

when you create categories and it will place the products image in the correct folder. This helps keep your products

and categories images separated based on category.

Link to comment
Share on other sites

Hi.

In the readme it look like this:

***FIND:

 

$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);

 

 

 

***CHANGE TO:(Earlier versions than oscommerce-2.2rc2a)

 

// BOF Categories and Products Images Folder Tree

$sql_data_array['products_image'] = tep_output_generated_category_path_fs($current_category_id) . tep_db_prepare_input($HTTP_POST_VARS['products_image']);

 

// EOF Categories and Products Images Folder Tree

 

I Have 2.2rc2a. Does I need to edit this section?

Link to comment
Share on other sites

When i try to insert new categories i get this message.

 

Warning: mkdir() [function.mkdir]: Permission denied in /home/w11001/domains/bjarud.se/public_html/admin/categories.php on line 90

 

Warning: chmod() [function.chmod]: No such file or directory in /home/w11001/domains/bjarud.se/public_html/admin/categories.php on line 91

 

Warning: Cannot modify header information - headers already sent by (output started at /home/w11001/domains/bjarud.se/public_html/admin/categories.php:90) in /home/w11001/domains/bjarud.se/public_html/admin/includes/functions/general.php on line 22

 

I FORGOT TO MAKE THE IMAGES CATALOG WRITEABLE :) NOW IT WORKS!

Edited by xciso
Link to comment
Share on other sites

No, you don't need to do it.

 

lildog

 

 

 

Hi.

In the readme it look like this:

***FIND:

 

$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);

 

 

 

***CHANGE TO:(Earlier versions than oscommerce-2.2rc2a)

 

// BOF Categories and Products Images Folder Tree

$sql_data_array['products_image'] = tep_output_generated_category_path_fs($current_category_id) . tep_db_prepare_input($HTTP_POST_VARS['products_image']);

 

// EOF Categories and Products Images Folder Tree

 

I Have 2.2rc2a. Does I need to edit this section?

Link to comment
Share on other sites

The setup is real funky...I didn't have time to fix it. Make sure all the images are in the correct folders and check your coding in product_info.php. And make sure you are using the latest version. When you are in admin is the path correct there?

 

lildog

Link to comment
Share on other sites

hi, i edited, but display:

 

Fatal error: Call to undefined function: tep_output_generated_category_path_fs() in /mounted-storage/home5/sub002/sc11209-JGHN/specslinkshop.com/admin/categories.php on line 232

 

 

so, anyone could help pls

Link to comment
Share on other sites

hi there,

i installed this contrib this morning ... at first glance, it's working perfectly : my 1000+ images are eventually sorted in sub-directories ... but as wafung mentioned it, it doesn't take in account special characters such as # & - and other foreign languages / encodage - commonly used in categories' names <_< (well, there are also some forbidden characters \ / : * ? " < > in directories' names) ...

Edited by ncis
Link to comment
Share on other sites

Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid/gid is 2177/0 is not allowed to access /mounted-storage/home5/sub002/******/images/111222 owned by uid/gid 99/99 in /mounted-storage/home5/sub002/s*****/admin/includes/classes/upload.php on line 86

 

 

any idea?

Edited by SLS
Link to comment
Share on other sites

hi there,

i installed this contrib this morning ... at first glance, it's working perfectly : my 1000+ images are eventually sorted in sub-directories ... but as wafung mentioned it, it doesn't take in account special characters such as # & - and other foreign languages / encodage - commonly used in categories' names <_< (well, there are also some forbidden characters \ / : * ? " < > in directories' names) ...

 

an easy solution consists in adding the needed characters in the definition of the function tep_output_generated_category_path_fs() ... edit the general.php file in your admin directory and make the suitable changes ... for instance, i was able to add the following special characters @ ! ' - é è & # by modifying the $dir_path variable into :

$dir_path = ereg_replace("[^a-z0-9._@!'-éè]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($calculated_category_path[$ii][$jj]['text']))));

Link to comment
Share on other sites

an easy solution consists in adding the needed characters in the definition of the function tep_output_generated_category_path_fs() ... edit the general.php file in your admin directory and make the suitable changes ... for instance, i was able to add the following special characters @ ! ' - é è & # by modifying the $dir_path variable into :

$dir_path = ereg_replace("[^a-z0-9._@!'-éè]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($calculated_category_path[$ii][$jj]['text']))));

 

don't do this !!! it's not a good idea 'cos you'll get directories / files with funny characters and your ftp client will be unable to delete them ... i'm having some hard time to do so (with additional php code) ...

Link to comment
Share on other sites

don't do this !!! it's not a good idea 'cos you'll get directories / files with funny characters and your ftp client will be unable to delete them ... i'm having some hard time to do so (with additional php code) ...

 

i figure out another way for deleting such directories / files by changing the characters encoding ... in the ftp manager : go to account manager -> advanced -> server encoding and when trying my region encoding (i.e. west european iso-8859-1), it works perfectly ... hence, the change in the general.php file is valid ...

Link to comment
Share on other sites

Hello

 

I cannot see any of the product images.

 

Got these warnings when I pressed "Keep Images"

Warning: copy(W:/www/oscommerce/images/chess_boards/graphics_cards/matrox/mg200mms.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/chess_boards/graphics_cards/matrox/mg400-32mb.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/chess_boards/mice/microsoft/msimpro.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/replacement_killers.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/science_fiction/dvd/blade_runner.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/the_matrix.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/comedy/dvd/youve_got_mail.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/cartoons/dvd/a_bugs_life.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/under_siege.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/under_siege2.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/fire_down_below.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/die_hard_3.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/lethal_weapon.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/drama/dvd/red_corner.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/thriller/dvd/frantic.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/drama/dvd/courage_under_fire.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/speed.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/action/dvd/speed_2.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/comedy/dvd/theres_something_about_mary.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/travel_chess_sets/drama/dvd/beloved.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/decorated_chess_sets/simulation/sierra/swat_3.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/decorated_chess_sets/painted_design/gt_interactive/unreal_tournament.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/decorated_chess_sets/strategy/gt_interactive/wheel_of_time.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/decorated_chess_sets/strategy/gt_interactive/disciples.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/chess_boards/keyboards/microsoft/intkeyboardps2.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/chess_boards/mice/microsoft/imexplorer.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: copy(W:/www/oscommerce/images/chess_boards/printers/hewlett_packard/lj1100xi.gif) [function.copy]: failed to open stream: No such file or directory in W:\www\oscommerce\security_panel\catimagessetup.php on line 230

Warning: Cannot modify header information - headers already sent by (output started at W:\www\oscommerce\security_panel\catimagessetup.php:230) in W:\www\oscommerce\security_panel\includes\functions\general.php on line 22

 

Any idea what I might have done wrong?

 

Thanks ... Dennis

Link to comment
Share on other sites

Dennis,

The setup script is not right and I don't have time to fix it. The contrib probably fixed your paths but didn't move the pictures into the correct folders on your server. This is a one time deal, move the pics to their correct folders and all should be well again.

 

lildog

Link to comment
Share on other sites

When I add a product and a image in the admin I can see it, but when I have done that I cant see the image in the store or in the admin. I can just see the image when i preview the product.

I have RC2a.

 

The same thing happens to me.

 

does not save the path of the images in the database.

 

Help

Link to comment
Share on other sites

Hi.

When I add a product and a image in the admin I can see it, but when I have done that I cant see the image in the store or in the admin. I can just see the image when i preview the product.

I have RC2a.

 

I'm working to find the solution, For fix it to the categories:

**IN admin/categories.php FIND:
         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_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_name_array[$language_id] . "/" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

 

When I find the solution to the products I report it ;)

Link to comment
Share on other sites

Hi.

When I add a product and a image in the admin I can see it, but when I have done that I cant see the image in the store or in the admin. I can just see the image when i preview the product.

I have RC2a.

 

The solution:

//IN admin/categories.php 
**FIND:
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_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_name_array[$language_id] . "/" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

**FIND all
$products_image_name2

**CHANGE TO:
$products_image_name

 

This solution works on my osCommerce. I hope to this help someone ;)

Link to comment
Share on other sites

Is anyone else having this problem? I am using RC2a also but do not have this problem. But I would like to integrate it in for others if need be.

 

lildog

 

Hi.

When I add a product and a image in the admin I can see it, but when I have done that I cant see the image in the store or in the admin. I can just see the image when i preview the product.

I have RC2a.

Link to comment
Share on other sites

  • 2 weeks later...
Hi.

When I add a product and a image in the admin I can see it, but when I have done that I cant see the image in the store or in the admin. I can just see the image when i preview the product.

I have RC2a.

I've got this same problem on RC2a, even after implementing xispita10's mod:

 

1) Add a new product and choose an image.

2) When I click "Preview", the image appears fine.

3) When I click "Insert", then check the Admin page or the Product page, the image is gone.

4) Image is in the proper subfolder.

 

Why aren't the admin and product pages finding the image? Seems the location is not being written to the database. Why?

 

Thanks for your help

Edited by matta
Link to comment
Share on other sites

I've got this same problem on RC2a, even after implementing xispita10's mod:

 

1) Add a new product and choose an image.

2) When I click "Preview", the image appears fine.

3) When I click "Insert", then check the Admin page or the Product page, the image is gone.

4) Image is in the proper subfolder.

 

Why aren't the admin and product pages finding the image? Seems the location is not being written to the database. Why?

 

Thanks for your help

 

OK, here's what I've determined:

 

There are 2 issues going on with xispita10's mod:

1) The folders create names from the Category name, but replace spaces with underscores (I assume this was done to accomodate web servers that don't like spaces in filenames).

So, a category name of "Bells and Whistles" becomes a folder name of "bells_and_whistles".

Using $categories_name_array[$language_id] to grab the category name still includes spaces and won't resolve to the proper folder.

 

Solution: Replace xispita10's code:

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_name_array[$language_id] . "/" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

 

With:

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_output_generated_category_path_fs($categories_id) . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

 

2) The $language_id is wrong:

Previously in the admin/categories.php, the code loops through $language_id['id'] and sets the values for each language (English, German, Spanish are the 3 defaults). When it ends, it leaves $language_id as the last value (3 in this example, or Spanish). If you're lazy like me and haven't filled in any of the fields other than English, the value will be blank.

So, when it tries to find $categories_name_array[$language_id] (which would be the blank Spanish value), it returns nothing, resulting in a missing directory.

 

Solution: Though maybe inelegent, I'd recommend hardcoding the $language_id to the number 1. This will force the category name to be (presumably) in the store owner's first language choice.

 

Any additional thoughts to make this better?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...