Jump to content

Undefined index: 2 in tools/smarty/plugins/function.declension.php


Recommended Posts

Hello!

 

After adding second language to PrestaShop, I've got error in any item form.

 

Notice: Undefined index: 2 in httpdocs/tools/smarty/plugins/function.declension.php on line 14

 

Here is code

 

function smarty_function_declension ($params,&$smarty) {
$totl = null;
$expressions = explode(',',$params['expressions']);

$count = $params['nb'] % 100;

if ($count >= 5 && $count <= 20) {
 $result = $totl . ' ' . $expressions['2'];  //HERE IS ERROR
} else {
 $count = $count % 10;
 if ($count == 1) {
  $result = $totl . ' ' . $expressions['0'];
 } elseif ($count >= 2 && $count <= 4) {
  $result = $totl . ' ' . $expressions['1'];
 } else {
  $result = $totl . ' ' . $expressions['2'];
 }
}
return $result;
}

 

As I understood problem is with $expressions, it should be defined in case if there is no value.

 

May be someone cloud help me with it?

Link to comment
Share on other sites

Thanks for your answer.

 

I know that it would be easier way how to fix this notice, but may be this value will be used later and there will be an error. So I'm trying to find "correct" solution.

Link to comment
Share on other sites

×
×
  • Create New...