Answer the question
In order to leave comments, you need to log in
Bitrix. How to output a custom property in breadcrumbs?
Good afternoon!
It is necessary to display the value of the text custom property of the section with the name of the menu item and the breadcrumb. If you tell me about the breadcrumb, that will be enough, I hope, to implement the menu as well.
Wandering through the materials led to the task of deriving the value of users. sv-va in the $arResult array. Is it possible? I ask you to specify the answer as much as possible, because Bitrix is a wild beast for me.
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
All right, I've decided. Thank you, kind person! I wouldn't have gone anywhere without your help.
I am posting the finished breadcrumb template code with a solved problem for the next generation of teapots. At the same time, I did not touch the component itself, only the template!
$strReturn = '<ul class="breadcrumb-navigation" xmlns:v="http://rdf.data-vocabulary.org/#">';
for($index = 0, $itemSize = count($arResult); $index < $itemSize; $index++)
{
if($index > 0) {
$strReturn .= '<li><span> > </span></li>';
$cutLink=explode("/", $arResult[$index]["LINK"]);//разбиваем путь на SECTION_CODE
$cnt=count($cutLink);//считаем количество элементов массива
$numSecNow=$cnt-2;//номер текущего (чпу со "/" на конце, поэтому -2)
$secNow=$cutLink["$numSecNow"];//нужный нам SECTION_CODE
}
else $secNow="first";//не обязательно ваще
//тут чудо-код нашего друга. спс за него!
$iblock_id = 1; //мы должны знать ID инфоблока каталога
$custom_name = 'UF_ALT_NAME'; //символьный код свойства для кастомного тайтла
if(CModule::IncludeModule("iblock")){
$dbSection = CIBlockSection::GetList(
array("SORT"=>"ASC"),//сортировка по возрастанию. нам все равно
array(
"IBLOCK_ID" => $iblock_id,//ищем наше свойство по ID инфоблока
"CODE" => $secNow//и по найденному SECTION_CODE
),
false,//хз че
array($custom_name)//тут собсно то, что нам нужно достать
);
if ($arSection = $dbSection->GetNext()){
$new_name = $arSection["$custom_name"];
}
}
$title = htmlspecialcharsex($arResult[$index]["TITLE"]);//из стандартного шаблона
if ($new_name) {//если нашли, что нам нужно, присваиваем его
$name=$new_name;
}
else {//если нет - оставляем стандартный
$name=$title;
}
if($arResult[$index]["LINK"] <> ""&&$index<(count($arResult)-1))//уже попсовый костыль, чтоб последняя крошка была без ссылки
$strReturn .= '<li><span typeof="v:Breadcrumb"><a href="'.$arResult[$index]["LINK"].'" title="'.$title.'" rel="v:url" property="v:title">'.$name.'</a><span></li>';
else
$strReturn .= '<li>'.$name.'</li>';
}
$strReturn .= "</ul> ";//$str
return $strReturn;
If the component in whose arResult you need to display a custom property is a Catalog, then in the editor you can choose which properties to display, they will be in the PROPERTIES array . For example, if you have catalog.section , then the SOMETHING property will be something like this: $arResult['ITEMS'][$i]['PROPERTIES']['SOMETHING'];
and its value will be here:
$arResult['ITEMS'][$i]['PROPERTIES']['SOMETHING']['VALUE'];
Thanks for the answer!
Everything is more or less clear with the catalog. parameters are set manually. And in the same crumbs, the algorithm for forming the $arResult array is incomprehensible (to me at least). In the output, the parameters are NAME and LINK. And at the output, the name of the section is taken automatically and the name of the menu item and breadcrumb, and they need to be configured manually. Such is the need for SEO.
Could you route this CIBlockSection::GetList class to the breadcrumbs component. What parameters to pass if arParams contains only the ID of the infoblock.. I already tried to write something there, but it didn’t work out..
Yes, it’s worth clarifying that you need to display the properties of the catalog component in the breadcrumb component.. :/
Thanks again!
But apparently that won't work. The old arResult is not overwritten. what should be in the component then? nothing? It doesn't come out either.
Another moment. The property used is the one that is optional UF_. then instead of
array('PROPERTY_'.$custom_name)
//будет так?
array('UF_ALT_NAME')
//а вместо
$new_name = $arSection['PROPERTY_'.$custom_name.'_VALUE'];
//сработает?
$new_name = $arSection['UF_ALT_NAME'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question