sh2gr
asked on
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_descripti on[$langua ges[$i]['i d']])) ? stripslashes($products_des cription[$ languages[ $i]['id']] ) : get_products_description($ pInfo->pro ducts_id, $languages[$i]['id']) ;
.......
echo draw_textarea_field('produ cts_descri ption[' . $languages[$i]['id'] . ']', 'soft', '100%', '20', (isset($products_descripti on[$langua ges[$i]['i d']])) ? stripslashes($products_des cription[$ languages[ $i]['id']] ) : get_products_description($ pInfo->pro ducts_id, $languages[$i]['id'])); //,'id="'.'products_descri ption' . $languages[$i]['id'] . '"');
Dimi
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_descripti
.......
echo draw_textarea_field('produ
Dimi
ASKER
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?
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?
post the code of get_products_description()
ASKER
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 _descripti on'];
}
function get_products_description($
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
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
But it don't writes into the database....i receive blank product descriptions when viewing in different than english language
>>>But it don't writes into the database....i receive blank product descriptions when viewing in different than english language
I didnt understand
I didnt understand
Do you function other than get_products_description() to display description or using the same function everywhere?
ASKER
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_descripti on'];
$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_attri bute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_s hipping, 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->field s);
$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-d ata"');
$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_i d, $languages[$i]['id']);
$pInfo->products_descripti on = get_products_description($ pInfo->pro ducts_id, $languages[$i]['id']);
$pInfo->products_url = get_products_url($pInfo->p roducts_id , $languages[$i]['id']);
} else {
$pInfo->products_name = db_prepare_input($products _name[$lan guages[$i] ['id']]);
$pInfo->products_descripti on = db_prepare_input($products _descripti on[$langua ges[$i]['i d']]);
$pInfo->products_url = db_prepare_input($products _url[$lang uages[$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(stripslas hes($value )));
}
}
$languages = get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
echo draw_hidden_field('product s_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslas hes($produ cts_name[$ languages[ $i]['id']] )));
echo draw_hidden_field('product s_descript ion[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslas hes($produ cts_descri ption[$lan guages[$i] ['id']]))) ;
echo draw_hidden_field('product s_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslas hes($produ cts_url[$l anguages[$ i]['id']]) ));
}
echo draw_hidden_field('product s_image', stripslashes($products_ima ge_name));
echo image_submit('button_back. gif', IMAGE_BACK, 'name="edit"') . ' ';
if (isset($_GET['pID'])) {
echo image_submit('button_updat e.gif', IMAGE_UPDATE);
} else {
echo image_submit('button_inser t.gif', IMAGE_INSERT);
}
echo ' <a href="' . href_link(FILENAME_CATEGOR IES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . image_button('button_cance l.gif', IMAGE_CANCEL) . '</a>';
This is the additional functions
Start document:
if (not_null($_POST)) {
$pInfo = new objectInfo($_POST);
$products_name = $_POST['products_name'];
$products_description = $_POST['products_descripti
$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_quantity_order_
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_s
p.products_sort_order
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION
where p.products_id = pd.products_id
and p.products_id = '" . (int)$_GET['pID'] . "'");
$pInfo = new objectInfo($product->field
$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
$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->
$pInfo->products_descripti
$pInfo->products_url = get_products_url($pInfo->p
} else {
$pInfo->products_name = db_prepare_input($products
$pInfo->products_descripti
$pInfo->products_url = db_prepare_input($products
}
$specials_price = get_products_special_price
**************************
at the page end
**************************
reset($_POST);
while (list($key, $value) = each($_POST)) {
if (!is_array($_POST[$key])) {
echo draw_hidden_field($key, htmlspecialchars(stripslas
}
}
$languages = get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
echo draw_hidden_field('product
echo draw_hidden_field('product
echo draw_hidden_field('product
}
echo draw_hidden_field('product
echo image_submit('button_back.
if (isset($_GET['pID'])) {
echo image_submit('button_updat
} else {
echo image_submit('button_inser
}
echo ' <a href="' . href_link(FILENAME_CATEGOR
If yes
If your function get_products_description()