Answer the question
In order to leave comments, you need to log in
How to get links to files?
Hello, there are 2 infoblocks, in one there are 2 additional ones. fields for uploading files, one field for uploading files in PDF, others in DOC, in another infoblock the "File" FILES field, which leads to the infoblock with files. As a result, when I display an infoblock with articles in them, I need to display these 2 links to the file, when I print the array, I see this picture
[FILES] => Array
(
[ID] => 6
[TIMESTAMP_X] => 2016-08-09 14:04:48
[IBLOCK_ID] => 2
[NAME] => Файлы
[ACTIVE] => Y
[SORT] => 500
[CODE] => FILES
[DEFAULT_VALUE] =>
[PROPERTY_TYPE] => E
[ROW_COUNT] => 1
[COL_COUNT] => 30
[LIST_TYPE] => L
[MULTIPLE] => N
[XML_ID] =>
[FILE_TYPE] =>
[MULTIPLE_CNT] => 5
[TMP_ID] =>
[LINK_IBLOCK_ID] => 5
[WITH_DESCRIPTION] => N
[SEARCHABLE] => N
[FILTRABLE] => N
[IS_REQUIRED] => N
[VERSION] => 1
[USER_TYPE] => EList
[USER_TYPE_SETTINGS] => Array
(
[size] => 1
[width] => 0
[group] => N
[multiple] => N
)
[HINT] =>
[PROPERTY_VALUE_ID] => 39
[VALUE] => 46
[DESCRIPTION] =>
[VALUE_ENUM] =>
[VALUE_XML_ID] =>
[VALUE_SORT] =>
[~VALUE] => 46
[~DESCRIPTION] =>
[~NAME] => Файлы
[~DEFAULT_VALUE] =>
)
Answer the question
In order to leave comments, you need to log in
If you write your own in a component (which is unlikely), then do this:
$res = CIBlockElement::GetList(
array(),
array(
'IBLOCK_ID' = 1, // Идентификатор ИБ статей
),
false,
false,
array(
'PROPERTY_FILES.PROPERTY_DOC', // Коды свойств с файлами
'PROPERTY_FILES.PROPERTY_PDF'
)
);
while($arFields = $res->GetNext()){
// Смотрите, что тут находится в $arFields, и доставайте файлы по идентификатору, с помощью метода CFile::GetByID либо CFile::GetPath
}
if(!empty($arResult['PROPERTIES']['FILES']['VALUE'])){
$res = CIBlockElement::GetList(
array(),
array(
'IBLOCK_ID' => $arResult['PROPERTIES']['FILES']['IBLOCK_ID'],
'ID' => $arResult['PROPERTIES']['FILES']['VALUE'],
'ACTIVE' => 'Y'
),
false,
false,
array(
'PROPERTY_DOC', // Коды свойств с файлами
'PROPERTY_PDF'
)
);
$files = array();
while($arFields = $res->GetNext()){
foreach(array('PDF', 'DOC') as $code){
$fullCode = "PROPERTY_$code_VALUE";
if($filePath = CFile::GetPath($arFields[$fullCode])){
$files[] = $filePath;
}
}
}
$arResult['PROPERTIES']['FILES']['LINKS'] = $files;
}
I pulled out the material with 46 id, but in the end I don’t know how to pull out 2 fields from it
Array
(
[ID] => 46
[~ID] => 46
[TIMESTAMP_X] => 09.08.2016 14:03:21
[~TIMESTAMP_X] => 09.08.2016 14:03:21
[TIMESTAMP_X_UNIX] => 1470729801
[~TIMESTAMP_X_UNIX] => 1470729801
[MODIFIED_BY] => 1
[~MODIFIED_BY] => 1
[DATE_CREATE] => 09.08.2016 14:03:21
[~DATE_CREATE] => 09.08.2016 14:03:21
[DATE_CREATE_UNIX] => 1470729801
[~DATE_CREATE_UNIX] => 1470729801
[CREATED_BY] => 1
[~CREATED_BY] => 1
[IBLOCK_ID] => 5
[~IBLOCK_ID] => 5
[IBLOCK_SECTION_ID] =>
[~IBLOCK_SECTION_ID] =>
[ACTIVE] => Y
[~ACTIVE] => Y
[ACTIVE_FROM] =>
[~ACTIVE_FROM] =>
[ACTIVE_TO] =>
[~ACTIVE_TO] =>
[DATE_ACTIVE_FROM] =>
[~DATE_ACTIVE_FROM] =>
[DATE_ACTIVE_TO] =>
[~DATE_ACTIVE_TO] =>
[SORT] => 500
[~SORT] => 500
[NAME] => Авторское право
[~NAME] => Авторское право
[PREVIEW_PICTURE] =>
[~PREVIEW_PICTURE] =>
[PREVIEW_TEXT] =>
[~PREVIEW_TEXT] =>
[PREVIEW_TEXT_TYPE] => text
[~PREVIEW_TEXT_TYPE] => text
[DETAIL_PICTURE] =>
[~DETAIL_PICTURE] =>
[DETAIL_TEXT] =>
[~DETAIL_TEXT] =>
[DETAIL_TEXT_TYPE] => text
[~DETAIL_TEXT_TYPE] => text
[SEARCHABLE_CONTENT] => АВТОРСКОЕ ПРАВО
[~SEARCHABLE_CONTENT] => АВТОРСКОЕ ПРАВО
[WF_STATUS_ID] => 1
[~WF_STATUS_ID] => 1
[WF_PARENT_ELEMENT_ID] =>
[~WF_PARENT_ELEMENT_ID] =>
[WF_LAST_HISTORY_ID] =>
[~WF_LAST_HISTORY_ID] =>
[WF_NEW] =>
[~WF_NEW] =>
[LOCK_STATUS] => green
[~LOCK_STATUS] => green
[WF_LOCKED_BY] =>
[~WF_LOCKED_BY] =>
[WF_DATE_LOCK] =>
[~WF_DATE_LOCK] =>
[WF_COMMENTS] =>
[~WF_COMMENTS] =>
[IN_SECTIONS] => N
[~IN_SECTIONS] => N
[SHOW_COUNTER] =>
[~SHOW_COUNTER] =>
[SHOW_COUNTER_START] =>
[~SHOW_COUNTER_START] =>
[CODE] => avtorskoe-pravo
[~CODE] => avtorskoe-pravo
[TAGS] =>
[~TAGS] =>
[XML_ID] => 46
[~XML_ID] => 46
[EXTERNAL_ID] => 46
[~EXTERNAL_ID] => 46
[TMP_ID] => 0
[~TMP_ID] => 0
[USER_NAME] => (seftomsk) Алексей Верховцев
[~USER_NAME] => (seftomsk) Алексей Верховцев
[LOCKED_USER_NAME] =>
[~LOCKED_USER_NAME] =>
[CREATED_USER_NAME] => (seftomsk) Алексей Верховцев
[~CREATED_USER_NAME] => (seftomsk) Алексей Верховцев
[LANG_DIR] => /
[~LANG_DIR] => /
[LID] => s1
[~LID] => s1
[IBLOCK_TYPE_ID] => services
[~IBLOCK_TYPE_ID] => services
[IBLOCK_CODE] => files
[~IBLOCK_CODE] => files
[IBLOCK_NAME] => Файлы
[~IBLOCK_NAME] => Файлы
[IBLOCK_EXTERNAL_ID] =>
[~IBLOCK_EXTERNAL_ID] =>
[DETAIL_PAGE_URL] => /services/detail.php?ID=46
[~DETAIL_PAGE_URL] => /services/detail.php?ID=46
[LIST_PAGE_URL] => /services/index.php?ID=5
[~LIST_PAGE_URL] => /services/index.php?ID=5
[CANONICAL_PAGE_URL] =>
[~CANONICAL_PAGE_URL] =>
[CREATED_DATE] => 2016.08.09
[~CREATED_DATE] => 2016.08.09
[BP_PUBLISHED] => Y
[~BP_PUBLISHED] => Y
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question