Multi languages & HTML editor(s)

Hello

As I will set up a multi language shop (with ENG as default), I want to ask if there is a way -when adding a new product- to have the english description displayed for each other languages.
So far.....(for 5 languages) I have 5 HTML editors displayed on my "new product" entry page and have to add 5 times the same Description, but I need only the english.
When nothing is entered for non english languages....nothing will be dispalyed inside the shop when switching between languages.

The section for the HTML editor (product description) is this:
......
$oFCKeditor->Value = (isset($products_description[$languages[$i]['id']])) ? stripslashes($products_description[$languages[$i]['id']]) : get_products_description($pInfo->products_id, $languages[$i]['id']) ;
.......
echo draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', (isset($products_description[$languages[$i]['id']])) ? stripslashes($products_description[$languages[$i]['id']]) : get_products_description($pInfo->products_id, $languages[$i]['id'])); //,'id="'.'products_description' . $languages[$i]['id'] . '"');

 

Dimi
sh2grAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Muhammad WasifCommented:
Do you want to display the description in english, if the non-english description is not available?

If yes
If your function get_products_description() returns the description from the DB, on the base language id specified. You can change this function behaviour in such a way, it returns english description if the non-english is not available.
0
sh2grAuthor Commented:
Hello

thats correct. I want the english description to be taken from the db if there is no other available (in the non english).
Some if function...right?

Well what would the code be?
0
Muhammad WasifCommented:
post the code of get_products_description()
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

sh2grAuthor Commented:
Ohh...right, sorry :-)  

function get_products_description($product_id, $language_id) {
    global $db;
    $product = $db->Execute("select products_description
                             from " . TABLE_PRODUCTS_DESCRIPTION . "
                             where products_id = '" . (int)$product_id . "'
                             and language_id = '" . (int)$language_id . "'");

    return $product->fields['products_description'];
  }
0
Muhammad WasifCommented:
function get_products_description($product_id, $language_id) {
    global $db;
    $english_id = 1;//replace 1 with the id of english
    $product = $db->Execute("select products_description
                             from " . TABLE_PRODUCTS_DESCRIPTION . "
                             where products_id = '" . (int)$product_id . "'
                             and language_id = '" . (int)$language_id . "'");

   //this will check if the language is non-english and description is not defined, get the english description from the db
   if(trim($product->fields['products_description'])=="" && $language_id!=$english_id)
      $product = $db->Execute("select products_description
                             from " . TABLE_PRODUCTS_DESCRIPTION . "
                             where products_id = '" . (int)$product_id . "'
                             and language_id = '" . $english_id . "'");

   return $product->fields['products_description'];
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sh2grAuthor Commented:
Thank you...so far so good, the description shows up in the non english fields (editors).
But it don't writes into the database....i receive blank product descriptions when viewing in different than english language

0
Muhammad WasifCommented:
>>>But it don't writes into the database....i receive blank product descriptions when viewing in different than english language

I didnt understand
0
Muhammad WasifCommented:
Do you function other than get_products_description() to display description or using the same function everywhere?
0
sh2grAuthor Commented:
Yes...my fault.  Before executing the "save new product", I can preview it at the new_product_preview page

This is the additional functions
Start document:

 if (not_null($_POST)) {
      $pInfo = new objectInfo($_POST);
      $products_name = $_POST['products_name'];
      $products_description = $_POST['products_description'];
      $products_url = $_POST['products_url'];
    } else {
      $products = $db->Execute("select p.products_id, pd.language_id, pd.products_name,
                                      pd.products_description, pd.products_url, p.products_quantity,
                                      p.products_model, p.products_image, p.products_price, p.products_virtual,
                                      p.products_weight, p.products_date_added, p.products_last_modified,
                                      p.products_date_available, p.products_status, p.manufacturers_id,
                                      p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                      p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                      p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
                    p.products_sort_order
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = pd.products_id
                               and p.products_id = '" . (int)$_GET['pID'] . "'");

      $pInfo = new objectInfo($product->fields);
      $products_image_name = $pInfo->products_image;
    }

    $form_action = (isset($_GET['pID'])) ? 'update_product' : 'insert_product';

    echo draw_form($form_action, $type_admin_handler, 'cPath=' . $cPath . (isset($_GET['product_type']) ? '&product_type=' . $_GET['product_type'] : '') . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=' . $form_action . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'post', 'enctype="multipart/form-data"');

    $languages = get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
      if (isset($_GET['read']) && ($_GET['read'] == 'only')) {
        $pInfo->products_name = get_products_name($pInfo->products_id, $languages[$i]['id']);
        $pInfo->products_description = get_products_description($pInfo->products_id, $languages[$i]['id']);
        $pInfo->products_url = get_products_url($pInfo->products_id, $languages[$i]['id']);
      } else {
        $pInfo->products_name = db_prepare_input($products_name[$languages[$i]['id']]);
        $pInfo->products_description = db_prepare_input($products_description[$languages[$i]['id']]);
        $pInfo->products_url = db_prepare_input($products_url[$languages[$i]['id']]);
      }

      $specials_price = get_products_special_price($pID);
*********************************************
at the page end
*********************************************
 reset($_POST);
      while (list($key, $value) = each($_POST)) {
        if (!is_array($_POST[$key])) {
          echo draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
        }
      }

      $languages = get_languages();
      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
        echo draw_hidden_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_name[$languages[$i]['id']])));
        echo draw_hidden_field('products_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_description[$languages[$i]['id']])));
        echo draw_hidden_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_url[$languages[$i]['id']])));
      }
      echo draw_hidden_field('products_image', stripslashes($products_image_name));

      echo image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '&nbsp;&nbsp;';

      if (isset($_GET['pID'])) {
        echo image_submit('button_update.gif', IMAGE_UPDATE);
      } else {
        echo image_submit('button_insert.gif', IMAGE_INSERT);
      }
      echo '&nbsp;&nbsp;<a href="' . href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.