Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question