function getNeighboringItems ($elementId, $sort = [], $filter = [])
{
Loader::includeModule('iblock');
$arrows = [];
$elements = CIBlockElement::GetList($sort, $filter, false, ['nElementID' => $elementId, 'nPageSize' => 1], ['ID', 'NAME', 'DETAIL_PAGE_URL']);
while ($element = $elements->GetNext())
$arrows[] = $element;
$result = ['LEFT' => [], 'RIGHT' => []];
if (count($arrows) == 3)
{
$result['LEFT'] = $arrows[0];
$result['RIGHT'] = $arrows[2];
}
elseif (count($arrows) == 2)
{
if ($arrows[0]['ID'] != $elementId)
$result['LEFT'] = $arrows[0];
if ($arrows[1]['ID'] != $elementId)
$result['RIGHT'] = $arrows[1];
}
return $result;
}