В Битриксе часто нужна проверка на какой странице показывать ту или иную информацию, например нам разместить слайдер только для страниц торгового каталога, этого нужно сделать простую проверку:
if(CSite::InDir("/catalog/")){ "bitrix:news.list", "main-slider", array( "ACTIVE_DATE_FORMAT" => "d.m.Y", "ADD_SECTIONS_CHAIN" => "N", "AJAX_MODE" => "Y", "AJAX_OPTION_ADDITIONAL" => "", "AJAX_OPTION_HISTORY" => "N", "AJAX_OPTION_JUMP" => "N", "AJAX_OPTION_STYLE" => "Y", "CACHE_FILTER" => "Y", "CACHE_GROUPS" => "Y", "CACHE_TIME" => "36000000", "CACHE_TYPE" => "A", "CHECK_DATES" => "N", "DETAIL_URL" => "", "DISPLAY_BOTTOM_PAGER" => "N", "DISPLAY_TOP_PAGER" => "N", "FIELD_CODE" => array( 0 => "PREVIEW_PICTURE", 1 => "", ), "FILTER_NAME" => "arrFilterHeaderSlider", "HIDE_LINK_WHEN_NO_DETAIL" => "N", "IBLOCK_ID" => "2", "IBLOCK_TYPE" => "slider", "INCLUDE_IBLOCK_INTO_CHAIN" => "N", "INCLUDE_SUBSECTIONS" => "Y", "MESSAGE_404" => "", "NEWS_COUNT" => "20", "PAGER_BASE_LINK_ENABLE" => "N", "PAGER_DESC_NUMBERING" => "N", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "N", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => ".default", "PAGER_TITLE" => "Слайдер", "PARENT_SECTION" => "", "PARENT_SECTION_CODE" => "", "PREVIEW_TRUNCATE_LEN" => "", "PROPERTY_CODE" => array( 0 => "URL", 1 => "", ), "SET_BROWSER_TITLE" => "N", "SET_LAST_MODIFIED" => "N", "SET_META_DESCRIPTION" => "N", "SET_META_KEYWORDS" => "N", "SET_STATUS_404" => "N", "SET_TITLE" => "N", "SHOW_404" => "N", "SORT_BY1" => "SORT", "SORT_BY2" => "NAME", "SORT_ORDER1" => "ASC", "SORT_ORDER2" => "ASC", "COMPONENT_TEMPLATE" => "main-slider", "STRICT_SECTION_CHECK" => "N", "COMPOSITE_FRAME_MODE" => "A", "COMPOSITE_FRAME_TYPE" => "AUTO" ), false ); } }
Не стоит путать эту функцию с $APPLICATION->GetCurPage()
, т.к. GetCurPage() проверяет на конкретную страницу, а CSite::InDir
проверяет ещё и вложенные подкаталоги.