Answer the question
In order to leave comments, you need to log in
Bitrix.Component call is perceived as text?
Here is the page template
<?php
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/**
* @global CMain $APPLICATION
*/
global $APPLICATION;
//delayed function must return a string
if(empty($arResult))
return "";
$strReturn = '';
//we can't use $APPLICATION->SetAdditionalCSS() here because we are inside the buffered function GetNavChain()
$css = $APPLICATION->GetCSSArray();
if(!is_array($css) || !in_array("/bitrix/css/main/font-awesome.css", $css))
{
$strReturn .= '<link href="'.CUtil::GetAdditionalFileURL("/bitrix/css/main/font-awesome.css").'" type="text/css" rel="stylesheet" />'."\n";
}
$strReturn .= '<div class="bx-breadcrumb">';
$itemSize = count($arResult);
for($index = 0; $index < $itemSize; $index++)
{
$title = htmlspecialcharsex($arResult[$index]["TITLE"]);
$nextRef = ($index < $itemSize-2 && $arResult[$index+1]["LINK"] <> ""? ' itemref="bx_breadcrumb_'.($index+1).'"' : '');
$child = ($index > 0? ' itemprop="child"' : '');
$arrow = ($index > 0? '<i class="fa fa-angle-right"></i>' : '');
if($arResult[$index]["LINK"] <> "" && $index != $itemSize-1)
{
}
else if(empty($arResult[2]))
{
$strReturn .= '
<ul class="crumbs">
<li><a href="/index.php">Главная</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/">Каталог</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/new/">Вилочные погрузчики</a></li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[1]["LINK"].'">'.$arResult[1]["TITLE"].'</a></li>
</ul>';
} else
{
$strReturn .= '
<ul class="crumbs">
<li><a href="/index.php">Главная</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/">Каталог</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/new/">Вилочные погрузчики</a>
<ul class="sub-menu">
<?$APPLICATION->IncludeComponent(
"bitrix:catalog.section.list",
"4k2_section_breadcrumb",
array(
"ADD_SECTIONS_CHAIN" => "Y",
"CACHE_GROUPS" => "Y",
"CACHE_TIME" => "36000000",
"CACHE_TYPE" => "A",
"COUNT_ELEMENTS" => "N",
"IBLOCK_ID" => "17",
"IBLOCK_TYPE" => "4k2_catalog",
"SECTION_CODE" => "",
"SECTION_FIELDS" => array(
0 => "NAME",
1 => "",
),
"SECTION_ID" => $_REQUEST["SECTION_ID"],
"SECTION_URL" => "#SITE_DIR#/catalog/new/#SECTION_ID#/",
"SECTION_USER_FIELDS" => array(
0 => "",
1 => "",
),
"SHOW_PARENT_NAME" => "Y",
"TOP_DEPTH" => "1",
"VIEW_MODE" => "LINE",
"COMPONENT_TEMPLATE" => ".default"
),
false
);?>
</ul>
</li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[1]["LINK"].'">'.$arResult[1]["TITLE"].'</a></li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[2]["LINK"].'">'.$arResult[2]["TITLE"].'</a></li>
</ul>';
}
}
$strReturn .= '<div style="clear:both"></div></div>';
return $strReturn;
Answer the question
In order to leave comments, you need to log in
in the example, even the component is displayed as text and it is immediately visible.
Take the component out of echo.
In general, calling a component from a component is not the best practice, you will have everything in the cache all the time.
<?php
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/**
* @global CMain $APPLICATION
*/
global $APPLICATION;
//delayed function must return a string
if(empty($arResult))
return "";
$strReturn = '';
//we can't use $APPLICATION->SetAdditionalCSS() here because we are inside the buffered function GetNavChain()
$css = $APPLICATION->GetCSSArray();
if(!is_array($css) || !in_array("/bitrix/css/main/font-awesome.css", $css))
{
$strReturn .= '<link href="'.CUtil::GetAdditionalFileURL("/bitrix/css/main/font-awesome.css").'" type="text/css" rel="stylesheet" />'."\n";
}
$strReturn .= '<div class="bx-breadcrumb">';
$itemSize = count($arResult);
for($index = 0; $index < $itemSize; $index++)
{
$title = htmlspecialcharsex($arResult[$index]["TITLE"]);
$nextRef = ($index < $itemSize-2 && $arResult[$index+1]["LINK"] <> ""? ' itemref="bx_breadcrumb_'.($index+1).'"' : '');
$child = ($index > 0? ' itemprop="child"' : '');
$arrow = ($index > 0? '<i class="fa fa-angle-right"></i>' : '');
if($arResult[$index]["LINK"] <> "" && $index != $itemSize-1)
{
}
else if(empty($arResult[2]))
{
$strReturn .= '
<ul class="crumbs">
<li><a href="/index.php">Главная</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/">Каталог</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/new/">Вилочные погрузчики</a></li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[1]["LINK"].'">'.$arResult[1]["TITLE"].'</a></li>
</ul>';
} else
{
$strReturn .= '
<ul class="crumbs">
<li><a href="/index.php">Главная</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/">Каталог</a></li style="padding: 0 10px 0 3px;"><li style="padding: 0 10px 0 3px;"><a href="/catalog/new/">Вилочные погрузчики</a>
<ul class="sub-menu">'?>
<?$APPLICATION->IncludeComponent(
"bitrix:catalog.section.list",
"4k2_section_breadcrumb",
array(
"ADD_SECTIONS_CHAIN" => "Y",
"CACHE_GROUPS" => "Y",
"CACHE_TIME" => "36000000",
"CACHE_TYPE" => "A",
"COUNT_ELEMENTS" => "N",
"IBLOCK_ID" => "17",
"IBLOCK_TYPE" => "4k2_catalog",
"SECTION_CODE" => "",
"SECTION_FIELDS" => array(
0 => "NAME",
1 => "",
),
"SECTION_ID" => $_REQUEST["SECTION_ID"],
"SECTION_URL" => "#SITE_DIR#/catalog/new/#SECTION_ID#/",
"SECTION_USER_FIELDS" => array(
0 => "",
1 => "",
),
"SHOW_PARENT_NAME" => "Y",
"TOP_DEPTH" => "1",
"VIEW_MODE" => "LINE",
"COMPONENT_TEMPLATE" => ".default"
),
false
);?>
<?'</ul>
</li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[1]["LINK"].'">'.$arResult[1]["TITLE"].'</a></li>
<li style="padding: 0 10px 0 3px;"><a href="'.$arResult[2]["LINK"].'">'.$arResult[2]["TITLE"].'</a></li>
</ul>';
}
}
$strReturn .= '<div style="clear:both"></div></div>';
return $strReturn;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question