Answer the question
In order to leave comments, you need to log in
Displaying a detailed picture of a section in the Bitrix news list?
Hello, I just can’t display a detailed picture of a section in the list of news
vardump says that there is no detailed picture at all, although I put it on the output
<?
if(!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();
$this->setFrameMode(true);
global $arTheme;
$bCompact = $arParams['COMPACT_VIEW'];
?>
<?use \Bitrix\Main\Localization\Loc;?>
<?if($arResult['SECTIONS']):?>
<div class="backs item-views services-items type_4 front<?=(isset($arParams['SECTION_CLASS']) && $arParams['SECTION_CLASS'] ? ' '.$arParams['SECTION_CLASS'] : '');?><?=(isset($arParams['SCROLL_CLASS']) && $arParams['SCROLL_CLASS'] ? ' '.$arParams['SCROLL_CLASS'] : '')?> <?=$bCompact ? 'compact-view' : ''?>">
<div class="maxwidth-theme">
<div class="row">
<div class="col-md-12">
<?if($arParams['PAGER_SHOW_ALL']):?>
<a class="show_all pull-right" href="<?=str_replace('#SITE'.'_DIR#', SITE_DIR, $arResult['LIST_PAGE_URL'])?>"><span><?=(strlen($arParams['SHOW_ALL_TITLE']) ? $arParams['SHOW_ALL_TITLE'] : GetMessage('S_TO_SHOW_ALL_SERVICES'))?></span></a>
<?endif;?>
<h2><?=($arParams["TITLE"] ? $arParams["TITLE"] : Loc::getMessage("TITLE_SERVICES"));?></h2>
<div class="clearfix"></div>
<section class="home-sports">
<img src="http://casalisport.ru/upload/181_n_gruppo_casali.jpg" class="img-responsive uomo">
<div class="items flexbox icons">
<?foreach($arResult['SECTIONS'] as $arItem):?>
<?
// edit/add/delete buttons for edit mode
$arSectionButtons = CIBlock::GetPanelButtons($arItem['IBLOCK_ID'], 0, $arItem['ID'], array('SESSID' => false, 'CATALOG' => true));
$this->AddEditAction($arItem['ID'], $arSectionButtons['edit']['edit_section']['ACTION_URL'], CIBlock::GetArrayByID($arItem['IBLOCK_ID'], 'SECTION_EDIT'));
$this->AddDeleteAction($arItem['ID'], $arSectionButtons['edit']['delete_section']['ACTION_URL'], CIBlock::GetArrayByID($arItem['IBLOCK_ID'], 'SECTION_DELETE'), array('CONFIRM' => GetMessage('CT_BNL_ELEMENT_DELETE_CONFIRM')));
// preview picture
if($bShowSectionImage = in_array('PREVIEW_PICTURE', $arParams['FIELD_CODE'])){
$bImage = strlen($arItem['~PICTURE']);
$arSectionImage = ($bImage ? CFile::ResizeImageGet($arItem['~PICTURE'], array('width' => 388, 'height' => 10000), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true) : array());
$imageSectionSrc = ($bImage ? $arSectionImage['src'] : '');
}
if($baShowSectionImage = in_array('DETAIL_PICTURE', $arParams['FIELD_CODE'])){
$baImage = strlen($arItem['~PICTURE']);
$arSectionaImage = ($baImage ? CFile::ResizeImageGet($arItem['~PICTURE'], array('width' => 388, 'height' => 10000), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true) : array());
$imageSectionaSrc = ($baImage ? $arSectionaImage['src'] : '');
}
?>
<a href="<?=$arItem['SECTION_PAGE_URL']?>"><div class="img" style="background-image:url('<?=$imageSectionaSrc?>')"></div><span><?=$arItem['NAME']?></span></a>
<?endforeach;?>
</div>
</section>
</div>
</div>
</div>
</div>
<?endif;?>
<?
global $arTheme, $arRegion;
// get all subsections of PARENT_SECTION or root sections
$arSectionsFilter = array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y');
$arParams['DEPTH_LEVEL'] = ($arParams['DEPTH_LEVEL'] ? $arParams['DEPTH_LEVEL'] : 1);
$start_level = ($arResult['SECTION']['PATH'][0]['DEPTH_LEVEL'] ? $arResult['SECTION']['PATH'][0]['DEPTH_LEVEL'] : 1);
$end_level = $arParams['DEPTH_LEVEL'];
if($arParams['PARENT_SECTION'])
{
$arParentSection = CCache::CIBLockSection_GetList(array('SORT' => 'ASC', 'NAME' => 'ASC', 'CACHE' => array('TAG' => CCache::GetIBlockCacheTag($arParams['IBLOCK_ID']), 'MULTI' => 'N')), array('ID' => $arParams['PARENT_SECTION']), false, array('ID', 'IBLOCK_ID', 'LEFT_MARGIN', 'RIGHT_MARGIN'), array('nPageSize' => $arParams['NEWS_COUNT']));
$arSectionsFilter = array_merge($arSectionsFilter, array(/*'SECTION_ID' => $arParams['PARENT_SECTION'],*/'>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'],'<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => '1'));
$arSectionsFilter['INCLUDE_SUBSECTIONS'] = 'Y';
$arSectionsFilter['<=DEPTH_LEVEL'] = $end_level;
}
else
{
$arSectionsFilter['<=DEPTH_LEVEL'] = $end_level;
}
$arResult['COUNT_SECTIONS'] = 0;
if($arTheme['SHOW_SECTIONS_REGION']['VALUE'] == 'Y' && $arTheme['USE_REGIONALITY']['DEPENDENT_PARAMS']['REGIONALITY_FILTER_ITEM']['VALUE'] == 'Y' && $arRegion){
$arSectionsID = array();
$arElementsFilter = ($GLOBALS[$arParams['FILTER_NAME']] ? array_merge(array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y'), $GLOBALS[$arParams['FILTER_NAME']]) : array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y'));
$arElements = CCache::CIblockElement_GetList(array("CACHE" => array("TAG" => CCache::GetIBlockCacheTag($arParams["IBLOCK_ID"]), 'MULTI' => 'Y')), $arElementsFilter, false, false, array('IBLOCK_SECTION_ID'));
if($arElements){
foreach($arElements as $arElement){
if($arElement['IBLOCK_SECTION_ID'] && !in_array($arElement['IBLOCK_SECTION_ID'], $arSectionsID)){
$arSectionsID[] = $arElement['IBLOCK_SECTION_ID'];
}
}
if($arSectionsID){
$arSectionsFilter['ID'] = $arSectionsID;
}
}
}
$arResult['SECTIONS'] = CCache::CIBLockSection_GetList(array('SORT' => 'ASC', 'NAME' => 'ASC', 'CACHE' => array('TAG' => CCache::GetIBlockCacheTag($arParams['IBLOCK_ID']), 'GROUP' => array('ID'), 'MULTI' => 'N')), $arSectionsFilter, false, array('ID', 'NAME', 'IBLOCK_ID', 'DEPTH_LEVEL', 'IBLOCK_SECTION_ID', 'SECTION_PAGE_URL', 'DESCRIPTION', 'DETAIL_PICTURE', 'PICTURE'));
$arSections = array();
$arSectionsFilter['DEPTH_LEVEL'] = 1;
$arSections = CCache::CIBLockSection_GetList(array('SORT' => 'ASC', 'NAME' => 'ASC', 'CACHE' => array('TAG' => CCache::GetIBlockCacheTag($arParams['IBLOCK_ID']), 'GROUP' => array('ID'), 'MULTI' => 'N')), $arSectionsFilter, false, array('ID'));
$arResult['COUNT_SECTIONS'] = count($arSections);
unset($arSectionsFilter['DEPTH_LEVEL']);
if($arResult['SECTIONS'])
{
$arSections = array();
foreach($arResult['SECTIONS'] as $key => $arSection)
{
$ipropValues = new \Bitrix\Iblock\InheritedProperty\SectionValues($arSection['IBLOCK_ID'], $arSection['ID']);
$arResult['SECTIONS'][$key]['IPROPERTY_VALUES'] = $ipropValues->getValues();
CPriority::getFieldImageData($arResult['SECTIONS'][$key], array('DETAIL_PICTURE'), 'SECTION');
}
if($arParams['SHOW_CHILD_SECTIONS'] == 'Y')
{
foreach($arResult['SECTIONS'] as $arItem)
{
if(!$arSections[$arItem['ID']] && $arItem['DEPTH_LEVEL'] == $start_level){
$arSections[$arItem['ID']] = $arItem;
}
}
foreach($arResult['SECTIONS'] as $arItem)
{
if($arSections[$arItem['IBLOCK_SECTION_ID']] && $arItem['DEPTH_LEVEL'] == $end_level ){
$arSections[$arItem['IBLOCK_SECTION_ID']]['CHILD'][$arItem['ID']] = $arItem;
}
}
}
else{
foreach($arResult['SECTIONS'] as $arItem)
{
if( $arItem['DEPTH_LEVEL'] == $start_level )
$arSections[$arItem['ID']] = $arItem;
elseif( $arItem['DEPTH_LEVEL'] == $end_level )
$arSections[$arItem['IBLOCK_SECTION_ID']]['CHILD'][$arItem['ID']] = $arItem;
}
// fill elements
foreach($arSections as $key => $arSection)
{
$arItems = CCache::CIBlockElement_GetList(array('SORT' => 'ASC', 'ID' => 'DESC', 'CACHE' => array('TAG' => CCache::GetIBlockCacheTag($arParams['IBLOCK_ID']))), array_merge($arSectionsFilter, array('SECTION_ID' => $arSection['ID'])), false, false, array('ID', 'NAME', 'IBLOCK_ID', 'DETAIL_PAGE_URL'));
if($arItems)
{
if(!$arSections[$key]['CHILD'])
$arSections[$key]['CHILD'] = $arItems;
else
$arSections[$key]['CHILD'] = array_merge($arSections[$key]['CHILD'], $arItems);
}
}
}
$arResult['SECTIONS'] = $arSections;
}
?>
["DETAIL_PICTURE"]=>
array(18) {
["ID"]=>
string(3) "423"
["TIMESTAMP_X"]=>
object(Bitrix\Main\Type\DateTime)#444 (1) {
["value":protected]=>
object(DateTime)#391 (3) {
["date"]=>
string(26) "2021-10-25 16:44:16.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Moscow"
}
}
["MODULE_ID"]=>
string(6) "iblock"
["HEIGHT"]=>
string(3) "391"
["WIDTH"]=>
string(3) "391"
["FILE_SIZE"]=>
string(4) "8447"
["CONTENT_TYPE"]=>
string(9) "image/png"
["SUBDIR"]=>
string(10) "iblock/ec8"
["FILE_NAME"]=>
string(36) "662de94a265zjguajrt3z6dzkmwjy9fd.png"
["ORIGINAL_NAME"]=>
string(16) "201_n_tennis.png"
["DESCRIPTION"]=>
string(0) ""
["HANDLER_ID"]=>
NULL
["EXTERNAL_ID"]=>
string(32) "107c7d12c6a6eaee2893b58c06786433"
["~src"]=>
bool(false)
["SRC"]=>
string(55) "/upload/iblock/ec8/662de94a265zjguajrt3z6dzkmwjy9fd.png"
["UNSAFE_SRC"]=>
string(55) "/upload/iblock/ec8/662de94a265zjguajrt3z6dzkmwjy9fd.png"
["ALT"]=>
string(12) "Теннис"
["TITLE"]=>
string(12) "Теннис"
}
Answer the question
In order to leave comments, you need to log in
echo basename('http://example/category/category-name1/pagename.html', '.html');
preg_match( "#.*?\/(.*?)\.html$#", 'http://example/category/category-name1/pagename.html', $matches );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question