foreach($arComments as &$arComment) {
$arComment['POST_DETAIL_TEXT'] = $arPosts[$arComment['POST_ID']]['DETAIL_TEXT'];
$arComment['ELEMENT']['NAME'] = $arElements[$arComment['POST_ID']]['NAME'];
$arComment['ELEMENT']['DETAIL_PAGE_URL'] = $arElements[$arComment['POST_ID']]['DETAIL_PAGE_URL'];
$arComment['ELEMENT']['LIST_PAGE_URL'] = $arElements[$arComment['POST_ID']]['LIST_PAGE_URL'];
}
unset($arComment);
$blogId = 1;
$arLastComment = [];
$dbRes = CBlogComment::GetList(
['ID' => 'DESC'],
['BLOG_ID' => $blogId],
false,
['nTopCount' => 1]
);
if($arRes = $dbRes->Fetch()) {
$arLastComment = $arRes;
}
echo '<pre>';
print_r($arLastComment);
echo '</pre>';
\Bitrix\Main\Loader::includeModule('iblock');
\Bitrix\Main\Loader::includeModule('blog');
$iblockId = 2;
$arComments = $arPostsId = $arPosts = $arElements = array();
$arSelectedFields = Array("ID", "BLOG_ID", "POST_ID", "PARENT_ID", "AUTHOR_ID", "AUTHOR_NAME", "AUTHOR_EMAIL", "AUTHOR_IP", "AUTHOR_IP1", "TITLE", "POST_TEXT", "DATE_CREATE","USER_NAME");
$dbRes = CBlogComment::GetList(
['ID' => 'DESC', 'DATE_CREATE' => 'DESC'],
[],
false,
false,
$arSelectedFields
);
while($arRes = $dbRes->Fetch()) {
$arComments[] = $arRes;
$arPostsId[] = $arRes['POST_ID'];
}
$arPostsId = array_unique($arPostsId);
$dbRes = CBlogPost::GetList(
['ID' => 'DESC'],
['ID' => $arPostsId]
);
while($arRes = $dbRes->Fetch()) {
$arPosts[$arRes['ID']] = $arRes;
}
$dbRes = \Bitrix\Iblock\PropertyTable::getList([
'select' => ['ID', 'CODE'],
'filter' => [
'=IBLOCK_ID' => $iblockId,
'=PROPERTY_TYPE' => \Bitrix\Iblock\PropertyTable::TYPE_NUMBER,
'=MULTIPLE' => 'N',
'=CODE' => [CIBlockPropertyTools::CODE_BLOG_POST]
]
]);
if($arRes = $dbRes->Fetch()) {
$propertyPostId = $arRes['ID'];
}
$dbRes = CIBlockElement::GetList(
[],
['=IBLOCK_ID' => $iblockId, 'PROPERTY_'.$propertyPostId => $arPostsId],
false,
false,
['ID', 'NAME', 'DETAIL_PAGE_URL', 'PROPERTY_'.$propertyPostId]
);
while($arRes = $dbRes->GetNext()) {
$propertyPostValue = $arRes['PROPERTY_'.$propertyPostId.'_VALUE'];
$arElements[$propertyPostValue] = $arRes;
}
foreach($arComments as &$arComment) {
$arComment['POST_DETAIL_TEXT'] = $arPosts[$arComment['POST_ID']]['DETAIL_TEXT'];
$arComment['ELEMENT']['NAME'] = $arElements[$arComment['POST_ID']]['NAME'];
$arComment['ELEMENT']['DETAIL_PAGE_URL'] = $arElements[$arComment['POST_ID']]['DETAIL_PAGE_URL'];
}
echo '<pre>';
print_r($arComments);
echo '</pre>';
<?if($arComments):?>
<div class="comments">
<?foreach($arComments as $arComment):?>
// здесь верстка коммента, тегам присваиваешь классы, стили переносишь в css
<?endforeach;?>
</div>
<?endif;?>
у меня ничего не добавилось, осталось 0/10. Ты потом убрал меня из приглашенных экспертов? Просто интересно, как это работает)