There are already some other approaches, but I think this one request less customization. The following example is for greek and english languages:
1. Open your products.tpl template.
2. Find the line with: <tr><td width="40%"><strong>{$product.name}</strong>.
3. Between <tr> and <td> insert the following code:
4. Change then <tr><td width="40%"><strong>{$product.name}</strong> to <tr><td width="40%"><strong>{$multilangproductname}</strong>
5. Change next line from {if $product.description}{$product.description}<br /> to {if $product.description}{$multilangproductdescr}<br />
In the product description write your description as: <greek>This is the greek description</greek><english>This is the english description</english>. The result is obvious I guess. If no <greek> AND no <english> tags are found, the raw description will be displayed.
The same goes with product name, so why the optional code? WHMCS uses product name in many places, not just in products.tpl (email templates for example). So you will need to modify more templates if you also need a multilingual product name, not just products.tpl.
In other words, use the $multilangproductdescr and $mlutilangproductname variables in place of the default $product.description and $product.name. Change the ifs in the above code according to your language needs, and/or replace else with if for more than two languages.
I hope you'll find this little tweak helpful. :)
Nasos
1. Open your products.tpl template.
2. Find the line with: <tr><td width="40%"><strong>{$product.name}</strong>.
3. Between <tr> and <td> insert the following code:
Code:
{php}
$myvar=$this->get_template_vars('product');
$pname=$myvar['name'];
// *********** Optional code starts here ***********
if( strpos($pname,'<greek>') !== FALSE && strpos($pname,'<english>') !== FALSE )
{
if( $this->get_template_vars('language') == 'greek' )
{
$pname=substr($pname,strpos($pname,'<greek>')+13);
$pname=substr($pname,0,strpos($pname,'</greek>'));
} else {
$pname=substr($pname,strpos($pname,'<english>')+15);
$pname=substr($pname,0,strpos($pname,'</english>'));
}
}
// *********** Optional code ends here ***********
$this->assign('multilangproductname',$pname);
if( isset($myvar['description']) )
{
$descr=$myvar['description'];
if( strpos($descr,'<greek>') !== FALSE && strpos($descr,'<english>') !== FALSE )
{
if( $this->get_template_vars('language') == 'greek' )
{
$descr=substr($descr,strpos($descr,'<greek>')+7);
$descr=substr($descr,0,strpos($descr,'</greek>'));
} else {
$descr=substr($descr,strpos($descr,'<english>')+9);
$descr=substr($descr,0,strpos($descr,'</english>'));
}
}
$this->assign('multilangproductdescr',$descr);
}
{/php}
5. Change next line from {if $product.description}{$product.description}<br /> to {if $product.description}{$multilangproductdescr}<br />
In the product description write your description as: <greek>This is the greek description</greek><english>This is the english description</english>. The result is obvious I guess. If no <greek> AND no <english> tags are found, the raw description will be displayed.
The same goes with product name, so why the optional code? WHMCS uses product name in many places, not just in products.tpl (email templates for example). So you will need to modify more templates if you also need a multilingual product name, not just products.tpl.
In other words, use the $multilangproductdescr and $mlutilangproductname variables in place of the default $product.description and $product.name. Change the ifs in the above code according to your language needs, and/or replace else with if for more than two languages.
I hope you'll find this little tweak helpful. :)
Nasos