Jump to content
Sign in to follow this  
doublesam

How to make this contribution multilingual?

Recommended Posts

Hi all,

 

I am working with the more_category_boxes contribution:

http://www.oscommerce.com/community/contri...+category+boxes

 

It works fine so far, and the contribution is simple to install. It allows the creation of new category boxes, with multilingual content, but the box title is only available in english.

 

How to make the title of these new boxes multilingual, as for the other boxes?

 

3 new files have been uploaded:

 

admin/more_categories.php

admin/includes/languages/english/more_categories.php

includes/boxes/more_categories.php

 

I guess I should work on the includes/boxes/more_categories.php file, to have the box title multilingual, such as the other boxes. The code of that file is:

 

<?php

/*

$Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright ? 2003 osCommerce

 

Released under the GNU General Public License

*/

 

function new_tep_show_category($boxId,&$cPath_array,&$tree,$counter)

{

global $cat_name; // CategoryBox Enhancement

for ($i=0; $i<$tree[$counter]['level']; $i++)

 

$categories_string = " ";

 

// $cPath_new = 'cPath=' . $tree[$counter]['path']; // CategoryBox Enhancement

$categories_string .= '<a href="';

 

if ($tree[$counter]['parent'] == 0)

 

$cPath_new = 'cPath=' . $counter;

 

else

 

$cPath_new = 'cPath=' . $tree[$counter]['path'];

 

// $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; // CategoryBox Enhancement

$categories_string .= tep_href_link(FILENAME_DEFAULT, 'infoBox=' . $boxId . '&' . $cPath_new) . '">';

 

 

// CategoryBox Enhancement

if (tep_has_category_subcategories($counter, 'image')) {

$categories_string .= tep_image(DIR_WS_IMAGES . $tree[$counter]['image'], $tree[$counter]['name'], '30', '30');

}

else {

$categories_string .= tep_image(DIR_WS_IMAGES . $tree[$counter]['image'], $tree[$counter]['name'], '30', '30');

}

if (isset($cPath_array) && in_array($counter, $cPath_array)) {

$categories_string .= '</b>';

}

// CategoryBox Enhancement

 

// display category name

 

/* uncomment this section if you want the little arrows to the left of the categories

if (tep_has_category_subcategories($counter)) {

$categories_string .= tep_image(DIR_WS_IMAGES . 'pointer_blue.gif', '');

}

else {

$categories_string .= tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '');

}

/* end section */

 

if ($boxId == $_SESSION['infoBox'] && isset($cPath_array) && in_array($counter, $cPath_array))

{

 

// commented for CategoryBox Enhancement $categories_string .= '<b>' . $tree[$counter]['name'] . '</b>';

$categories_string .= '<b>';

 

// CategoryBox Enhancement

if ($cat_name == $tree[$counter]['name']) {

$categories_string .= '<span class="errorText">';

}

// CategoryBox Enhancement

 

$categories_string .= $tree[$counter]['name'];

 

// CategoryBox Enhancement

if ($cat_name == $tree[$counter]['name']) {

$categories_string .= '</span>';

}

// CategoryBox Enhancement

 

$categories_string .= '</b>';

}

 

else

{

// CategoryBox Enhancement

if ($cat_name == $tree[$counter]['name']) {

$categories_string .= '<b><span class="errorText">';

}

// CategoryBox Enhancement

 

$categories_string .= $tree[$counter]['name'];

 

// CategoryBox Enhancement

if ($cat_name == $tree[$counter]['name']) {

$categories_string .= '</span></b>';

}

// CategoryBox Enhancement

}

 

/* commented for CategoryBox Enhancement

if (tep_has_category_subcategories($counter))

 

$categories_string .= '->';

*/

 

$categories_string .= '</a>';

 

if (SHOW_COUNTS == 'true') {

 

$products_in_category = tep_count_products_in_category($counter);

 

if ($products_in_category > 0)

 

$categories_string .= ' (' . $products_in_category . ')';

 

}

 

$categories_string .= '<br>';

 

if ($tree[$counter]['next_id'] != false)

 

$categories_string .= new_tep_show_category($boxId,$cPath_array,$tree,$tree[$counter]['next_id']);

 

return $categories_string;

}

 

function tep_categories_box($boxId,&$infoBox,$follow_cPath,&$cPath_array)

{

global $languages_id;

 

$info_box_contents = array();

$info_box_contents[] = array('text' => $infoBox['name']);

 

new infoBoxHeading($info_box_contents, true, false);

 

$tree = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id in (".implode(',',$infoBox['categories']).") and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

 

$tree[$categories['categories_id']] = array(

'name' => $categories['categories_name'],

'image' => $categories['categories_image'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false

);

 

if (isset($parent_id))

$tree[$parent_id]['next_id'] = $categories['categories_id'];

 

$parent_id = $categories['categories_id'];

 

if (!isset($first_element))

$first_element = $categories['categories_id'];

 

}

 

//------------------------

if ($follow_cPath) {

 

$new_path = '';

 

reset($cPath_array);

 

while (list($key, $value) = each($cPath_array)) {

 

unset($parent_id);

unset($first_id);

 

$categories_query = tep_db_query("select c.categories_id, c.categories_image, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

 

if (tep_db_num_rows($categories_query)) {

 

$new_path .= $value;

 

while($row = tep_db_fetch_array($categories_query)) {

 

$tree[$row['categories_id']] = array(

'name' => $row['categories_name'],

'image' => $row['categories_image'],

'parent' => $row['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $row['categories_id'],

'next_id' => false

);

 

if (isset($parent_id))

 

$tree[$parent_id]['next_id'] = $row['categories_id'];

 

 

$parent_id = $row['categories_id'];

 

if (!isset($first_id))

 

$first_id = $row['categories_id'];

 

 

$last_id = $row['categories_id'];

 

}

 

$tree[$last_id]['next_id'] = $tree[$value]['next_id'];

 

$tree[$value]['next_id'] = $first_id;

 

$new_path .= '_';

 

} else {

 

break;

 

}

 

}

 

}

 

$info_box_contents = array();

$info_box_contents[] = array('text' => new_tep_show_category($boxId,$cPath_array,$tree,$first_element));

 

new infoBox($info_box_contents);

}

 

?>

<!-- categories //-->

<?php

 

$_infoBox = array();

 

// define('TABLE_CATEGORIES_MORE','categories_more');

 

$categories_this_infobox_query = tep_db_query("select * from " . TABLE_CATEGORIES_MORE . " where enabled = 1");

 

while ($_categories = tep_db_fetch_array($categories_this_infobox_query))

 

$_infoBox[] = array(

'categories' => array(

$_categories['category1_id'],

$_categories['category2_id'],

$_categories['category3_id'],

$_categories['category4_id'],

$_categories['category5_id'],

$_categories['category6_id'],

$_categories['category7_id'],

$_categories['category8_id'],

$_categories['category9_id'],

$_categories['category10_id'],

$_categories['category11_id'],

$_categories['category12_id'],

$_categories['category13_id'],

$_categories['category14_id'],

$_categories['category15_id'],

$_categories['category16_id'],

$_categories['category17_id'],

$_categories['category18_id'],

$_categories['category19_id'],

$_categories['category20_id'],

$_categories['category21_id'],

$_categories['category22_id'],

$_categories['category23_id'],

$_categories['category24_id'],

$_categories['category25_id'],

),

'name' => $_categories['infobox_name'],

'enabled' => $_categories['enabled']

);

 

if (!tep_session_is_registered('infoBox')) {

 

tep_session_register('infoBox');

 

$infoBox = '0';

 

}

 

if (isset($_GET['infoBox']) && is_numeric($_GET['infoBox']))

$infoBox = $_GET['infoBox'];

 

for($i=0,$n=count($_infoBox); $i<$n; $i++) {

 

echo "<tr>\n<td>\n";

 

tep_categories_box(

$i,

$_infoBox[$i],

($infoBox == $i && tep_not_null($cPath)) ? true : false,

$cPath_array

);

 

echo "\n</td>\n</tr>\n";

 

}

?>

<!-- categories_eof //-->

In that code, the instruction regarding the title is:

'name' => $_categories['infobox_name'],

 

I might also say that a new table, `categories_more`, has been added to the database, in which the 'infobox_name' is defined.

 

How could I modify that code to make the box title multilingual, like the other boxes? Obviously, you might have notices that my PHP knowledge is scarce...

 

Many thanks for help!

 

Doublesam

Share this post


Link to post
Share on other sites

Hi ,

 

I think I should do it in the same way than it is done in the box Categories, for the Category names . The Category names change according to language in the Category box. I want the same but for the title in the More Category boxes.

 

I should have to create an additional table in the database, for instance called more_categories_title.

This table should have 3 fields, in the same way than the categories_description table

Box_id

Language_id

Infobox_name

 

What would be the instruction to have the box title changing according to language?

I think I should copy the code that is used in boxes/categories.php, but I don?t know exactly how to integrate it:

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],

'parent' => $categories['parent_id'],

'level' => 0,

'path' => $categories['categories_id'],

'next_id' => false);

 

Anyone could help me? Many thanks because I 'm lost...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×