protected function _getPosition($entity, $childrenCount = false) {
		extract($this->_config);

		$parent = $this->_getById($entity->$parent);

		if ($entity->$left === ($parent->$left + 1)) {
			return 0;
		}

		if (($entity->$right + 1) === $parent->$right) {
			if ($childrenCount === false) {
				$childrenCount = $parent->childrens(false, 'count');
			}
			return $childrenCount - 1;
		}

		$count = 0;
		$children = $parent->childrens(false);

		$id = $entity->data($model::key());
		foreach ($children as $child) {
			if ($child->data($model::key()) === $id) {
				return $count;
			}
			$count++;
		}

		return false;
	}
protected function _getPosition($entity, $childrenCount = false) {
		extract($this->_config);

		$parent = $this->_getById($entity->$parent);

		if ($entity->$left === ($parent->$left + 1)) {
			return 0;
		}

		if (($entity->$right + 1) === $parent->$right) {
			if ($childrenCount === false) {
				$childrenCount = $parent->childrens(false, 'count');
			}
			return $childrenCount - 1;
		}

		$count = 0;
		$children = $parent->childrens(false);

		$id = $entity->data($model::key());
		foreach ($children as $child) {
			if ($child->data($model::key()) === $id) {
				return $count;
			}
			$count++;
		}

		return false;
	}
protected function _getPosition ( $ entity , $ childrenCount = false ) { extract ( $ this -> _config ) ; $ parent = $ this -> _getById ( $ entity -> $ parent ) ; if ( $ entity -> $ left === ( $ parent -> $ left + 1 ) ) { return 0 ; } if ( ( $ entity -> $ right + 1 ) === $ parent -> $ right ) { if ( $ childrenCount === false ) { $ childrenCount = $ parent -> childrens ( false , 'count' ) ; } return $ childrenCount - 1 ; } $ count = 0 ; $ children = $ parent -> childrens ( false ) ; $ id = $ entity -> data ( $ model :: key ( ) ) ; foreach ( $ children as $ child ) { if ( $ child -> data ( $ model :: key ( ) ) === $ id ) { return $ count ; } $ count ++ ; } return false ; }
Returns the current position number of an element at the same level,
where 0 is first position

@param object $entity the entity node to get the position from.
@param integer $childrenCount number of children of entity's parent,
performance parameter to avoid double select.
Returns the current position number of an element at the same level where 0 is first position