Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category Description Contribution help


gwmbox

Recommended Posts

Hi

 

I am trying to add the Category Description 1.1 Contribution and have been working through the readme to install the contribution but have now got stuck on the following.

 

The readme says to find

 

$categories_image = tep_get_uploaded_file('categories_image');
$image_directory = tep_get_local_path(DIR_FS_CATALOG_IMAGES);

       if (is_uploaded_file($categories_image['tmp_name'])) {
         tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_image['name'] . "' where categories_id = '" . tep_db_input($categories_id) . "'");
         tep_copy_uploaded_file($categories_image, $image_directory);
       }

 

and replace it with

 

          if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {
           tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $HTTP_POST_VARS['categories_image'] . "' where categories_id = '" .  tep_db_input($categories_id) . "'");
           $categories_image = '';
         } else {
           $categories_image = tep_get_uploaded_file('categories_image');
           $image_directory = tep_get_local_path(DIR_FS_CATALOG_IMAGES);
           if (is_uploaded_file($categories_image['tmp_name'])) {
             tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . $categories_image['name'] . "' where categories_id = '" . tep_db_input($categories_id) . "'");
             tep_copy_uploaded_file($categories_image, $image_directory);
           }
         }

 

Which I am happy to do but I have also added other contributions and the code to find has changed, so I am not sure what I need to change, the following is my code from line 69 to to 129 which I am pretty sure contains the stuff I need to edit

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

         tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
       }

       $languages = tep_get_languages();
       for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
         $categories_name_array = $HTTP_POST_VARS['categories_name'];

         $language_id = $languages[$i]['id'];

         $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

         if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {
         $sql_data_array = array('categories_name' => tep_db_prepare_input($HTTP_POST_VARS['categories_name'][$language_id]),
                                     'categories_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['categories_heading_title'][$language_id]),
                                     'categories_description' => tep_db_prepare_input($HTTP_POST_VARS['categories_description'][$language_id]));
           }
         if ($action == 'insert_category') {
           $insert_sql_data = array('categories_id' => $categories_id,
                                    'language_id' => $languages[$i]['id']);

           $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

           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 (HTML_AREA_WYSIWYG_DISABLE == 'Disable') {
         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 . "'");
         }
       } else {
         if (isset($HTTP_POST_VARS['categories_image']) && tep_not_null($HTTP_POST_VARS['categories_image']) && ($HTTP_POST_VARS['categories_image'] != 'none')) {
           tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($HTTP_POST_VARS['categories_image']) . "' where categories_id = '" . (int)$categories_id . "'");
         }
       }

       if (USE_CACHE == 'true') {
         tep_reset_cache_block('categories');
         tep_reset_cache_block('also_purchased');
       }

       tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
       break;
     case 'delete_category_confirm':
       if (isset($HTTP_POST_VARS['categories_id'])) {
         $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

         $categories = tep_get_category_tree($categories_id, '', '0', '', true);
         $products = array();
         $products_delete = array();

         for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
           $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");

           while ($product_ids = tep_db_fetch_array($product_ids_query)) {
             $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
           }
         }

 

Can someone please tell me how and what to change please.

 

Thanks

 

Greg

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...