E
E
Evgeny Nikolaev2019-08-28 12:19:49
1C-Bitrix
Evgeny Nikolaev, 2019-08-28 12:19:49

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

4 answer(s)
I
ivashjke, 2019-08-28
@ivashjke

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

A
Alexander Zemlyanoy, 2019-08-28
@Galamoon

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');?>

K
Kudis, 2019-08-28
@kudis

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');

And the crumbs themselves in the header are forbidden to be shown by some property of the page

A
Alexander, 2019-09-04
Madzhugin @Suntechnic

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).

No, and it cannot be - the breadcrumb component itself is essentially the same deferred function.
The idea is to get into the variables of h.c. inside the component itself is not very good - because they can change even in the footer.
It turns out that you want to get a variable before setting it.
Keane will not.
The correct solution is to do the right layout that won't break your news.list template or make two news.lists per page with breadcrumbs in between.
The wrong solution is to use GetNavChain in the news.list template - so get the chain formed by the time the template is displayed and do what you want with it. In principle, this will work, but don't be surprised if something happens...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question