A
A
Alexander Ivanov2016-06-27 18:13:12
PHP
Alexander Ivanov, 2016-06-27 18:13:12

How to extract a property from an infoblock?

<?$APPLICATION->IncludeComponent(
  "bitrix:news.list",
  "main-newsTest",
  Array(
    "ACTIVE_DATE_FORMAT" => "d.m.Y",
    "ADD_SECTIONS_CHAIN" => "Y",
    "AJAX_MODE" => "N",
    "AJAX_OPTION_ADDITIONAL" => "",
    "AJAX_OPTION_HISTORY" => "N",
    "AJAX_OPTION_JUMP" => "N",
    "AJAX_OPTION_STYLE" => "N",
    "CACHE_FILTER" => "Y",
    "CACHE_GROUPS" => "Y",
    "CACHE_TIME" => "3600",
    "CACHE_TYPE" => "Y",
    "CHECK_DATES" => "Y",
    "DETAIL_URL" => "",
    "DISPLAY_BOTTOM_PAGER" => "Y",
    "DISPLAY_DATE" => "Y",
    "DISPLAY_NAME" => "Y",
    "DISPLAY_PICTURE" => "Y",
    "DISPLAY_PREVIEW_TEXT" => "Y",
    "DISPLAY_TOP_PAGER" => "N",
    "FIELD_CODE" => array("",""),
    "FILTER_NAME" => "arrFilterTomain",
    "HIDE_LINK_WHEN_NO_DETAIL" => "Y",
    "IBLOCK_ID" => "31",
    "IBLOCK_TYPE" => "-",
    "INCLUDE_IBLOCK_INTO_CHAIN" => "Y",
    "INCLUDE_SUBSECTIONS" => "Y",
    "MESSAGE_404" => "",
    "NEWS_COUNT" => "6",
    "PAGER_BASE_LINK_ENABLE" => "N",
    "PAGER_DESC_NUMBERING" => "N",
    "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
    "PAGER_SHOW_ALL" => "N",
    "PAGER_SHOW_ALWAYS" => "Y",
    "PAGER_TEMPLATE" => ".default",
    "PAGER_TITLE" => "Новости",
    "PARENT_SECTION" => "",
    "PARENT_SECTION_CODE" => "",
    "PREVIEW_TRUNCATE_LEN" => "200",
    "PROPERTY_CODE" => array("CITYS",""),
    "SET_BROWSER_TITLE" => "Y",
    "SET_LAST_MODIFIED" => "N",
    "SET_META_DESCRIPTION" => "Y",
    "SET_META_KEYWORDS" => "Y",
    "SET_STATUS_404" => "Y",
    "SET_TITLE" => "Y",
    "SHOW_404" => "N",
    "SORT_BY1" => "ID",
    "SORT_BY2" => "SORT",
    "SORT_ORDER1" => "DESC",
    "SORT_ORDER2" => "ASC"
  )
);?>

From main-newsTest I would do it like this
<?$cityID= $arItem['DISPLAY_PROPERTIES']['CITYS']['VALUE'];echo $cityID;?>

or easier.
But how to extract CITYS value in one file with $APPLICATION->IncludeComponent?
Something like this:
$APPLICATION->IncludeComponent( ... )
//какой-то таинственный код выводящий $CITYS
echo  $CITYS;

That in one file, instead of in a component?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2016-06-27
@cimonlebedev

I think the answer can be found in the most unexpected place .
I would create an array of properties that can be manipulated directly and then passed to "IncludeComponent".

A
Alexander Ivanov, 2016-06-29
@cimonlebedev

example

<?
            		//вывожу дату
            		$IBLOCK_ID = intval($arParams['IBLOCK_ID']);
            		//print $IBLOCK_ID;
            		if(!CModule::IncludeModule("iblock"))
            				die('iblock module is not included!');
            		$arSort = Array("SORT"=>"ASC", "NAME"=>"ASC");
            		$arSelect = Array("ID","NAME","PROPERTY_DATA_SOBYTIYA");
            		$arFilter = Array("IBLOCK_ID"=>$IBLOCK_ID,"ACTIVE" => "Y", ">=DATE_ACTIVE_FROM" => $curdate, "PROPERTY" => array('ADD_TO_EVENTS' => array('VALUE' => 'Y')), "<=DATE_ACTIVE_FROM" => $curdatelast);
            		$arFilterDate = Array("IBLOCK_ID" => $IBLOCK_ID);
            		$obIBlockResult = CIBlockElement::GetList($arSort, $arFilter, false, false, $arSelect);
            		$arFilter = $obIBlockResult->GetNext();
            		?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question