Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Решено] Правильные окончания (helper)


Recommended Posts

Захотел окончания правильные сделать, вылазиет 1 раз ошибка и после рефреша исчезает, т.е. на новых куках ошибки... как исправить? 
 

Notice: Undefined index: language in category.php 
Undefined variable: endingArray in helper/ending.php on line 17
Undefined variable: endingArray in helper/ending.php on line 25

В контролере categoty.php
 

$this->load->helper('ending');
$data['products'][] = array(
...
'reviews'      => reviewEnding((int)$result['reviews'], $this->request->cookie['language']),
);

В ending.php 
 

function reviewEnding($number, $language) {
	$number = $number % 100;
	if ($language == 'ru-ru') {
		$endingArray = array("отзыв", "отзыва", "отзывов");
	} elseif ($language == 'ua') {
		$endingArray = array( "відгук", "відгуки", "відгуків" );
	} elseif ($language == 'en') {
		$endingArray = array( "review", "reviews", "reviews" );
	}
	if ($number >= 11 && $number <= 19) {
		$ending = $endingArray[2];
	} else {
		$i = $number % 10;
		switch ($i) {
			case (1):
17.				$ending = $endingArray[0];
				break;
			case (2):
			case (3):
			case (4):
			$ending = $endingArray[1];
			break;
			default:
25.				$ending = $endingArray[2];
		}
	}
	return $number . ' ' . $ending;
}

 

Edited by zik920
Link to comment
Share on other sites


да тут проблема-то вот в чем, ладно с кукой

 

function reviewEnding($number, $language) {
    $number = $number % 100;
    if ($language == 'ru-ru') {
        $endingArray = array("отзыв", "отзыва", "отзывов");
    } elseif ($language == 'ua') {
        $endingArray = array( "відгук", "відгуки", "відгуків" );
    } else {
        $endingArray = array( "review", "reviews", "reviews" );
    }

вот и все решение

Link to comment
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
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.