• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/publicaction/utils.php
  • Класс: BitrixLandingPublicActionUtils
  • Вызов: Utils::getIblockURL
static function getIblockURL($elementId, $urlType)
{
	static $urls = array();
	static $settings = array();

	$elementId = (int)$elementId;
	$key = (string)$urlType . '_' . $elementId;

	if (isset($urls[$key]))
	{
		return $urls[$key];
	}

	if (!BitrixMainLoader::includeModule('iblock'))
	{
		return $urls[$key];
	}

	if (empty($settings))
	{
		BitrixLandingHook::setEditMode(true);
		$settings = BitrixLandingHookPageSettings::getDataForSite();
	}

	$urls[$key] = '#system_catalog';
	$iblockId = $settings['IBLOCK_ID'];

	// build url
	if ($urlType == 'detail' || $urlType == 'element')
	{
		// element additional info
		$res = BitrixIblockElementTable::getList(array(
			'select' => array(
				'ID', 'CODE', 'IBLOCK_SECTION_ID'
			),
			'filter' => array(
				'ID' => $elementId,
				'IBLOCK_ID' => $iblockId
			)
		));
		if (!($element = $res->fetch()))
		{
			return $urls[$key];
		}
		// build url
		$urls[$key] .= 'item/' . $element['CODE'] . '/';
	}
	elseif ($urlType == 'section')
	{
		$res = CIBlockSection::getNavChain(
			$iblockId,
			$elementId
		);
		while ($row = $res->fetch())
		{
			$urls[$key] .= $row['CODE'] . '/';
		}
	}

	return $urls[$key];
}