Answer the question
In order to leave comments, you need to log in
How to make sure that Bitrix breadcrumbs are not displayed in the browser, but fall into a variable?
The situation is the following. On one of the pages of the site, due to the unusual design, it is required that breadcrumbs be displayed in the middle of the news:list template.
I understand that someone would like to discuss this option for the correctness of such a layout, but the essence is that there is a technical specification and the layout should be just like that.
In the new sheet, the loop on $arResult is used 3 times, because it displays information from the infoblock element in different div blocks that are not nested into each other. A couple of such blocks are separated, among other things, by calling bread crumbs.
If you just insert a call to the breadcrumb component into the newl:list template, you notice that the part of the news-list template that is above the breadcrumbs is cut out of the html, which leads to the crash of the page and, of course, you can’t leave it like that.
I understand that you can make 2 new: list templates and call first one, then breadcrumbs, then another news sheet for the same info block, and everything would work fine, but then the number of displayed elements and other settings need to be insisted in each or write common variables - these are not the best option. Besides it would be desirable to understand how to make through 1 news:list.
I tried to start buffering in result_modifier.php and then substitute breadcrumbs in component_epilog.php in the right place, but it turns out that as soon as breadcrumbs are connected, they turn off buffering and it is not possible to process the html part where they are contained.
I also don’t see the possibility of deferred functions, since the place to insert is inside the new-list template, and not in the header.
From the hypothetical solutions, I suppose it’s possible to rewrite the component so that it will return the result of the used breadcrumb component not to the browser, but as a variable, I somehow read about this method, but until now I haven’t tried to do it.
I think that I have described the situation enough, is there any standard solution? (Of course, except for the option - fix the layout so that the breadcrumbs are in the header).
Answer the question
In order to leave comments, you need to log in
ob_start();
attaching a component with breadcrumbs
$APPLICATION->SetPageProperty("breadcrumbs", ob_get_clean());
then output where needed $APPLICATION->ShowProperty('breadcrumbs');
or include them in header
ob_start();
attaching the breadcrumbs component
$breadcrumbs = ob_get_clean();
then output, if you really want through a variable
bitrix has a wrapper over output streams.
<?$this->SetViewTarget('news_detail');?>
<noindex><a rel="nofollow" class="h1-head fancy" href="/develop/change_cover_type.php"><?=$arDataFilter["NAME"]?></a></noindex>
<?$this->EndViewTarget();?>
//Вывести где нужно
<?$APPLICATION->ShowViewContent('news_detail');?>
There are 2 options:
1. Output data from news.list to its component_epilog, in which you will call, among other things, also a breadcrumb component, which will work fine
2. Output data from news_list to the page in chunks via ShowViewContent
$APPLICATION->ShowViewContent('news_part_1');
// что нибудь
$APPLICATION->ShowViewContent('news_part_2');
// компонент крошек
$APPLICATION->ShowViewContent('news_part_3');
I think that I have described the situation enough, is there any standard solution? (Of course, except for the option - fix the layout so that the breadcrumbs are in the header).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question