G
G
Greg Plitt2016-07-06 12:03:51
1C-Bitrix
Greg Plitt, 2016-07-06 12:03:51

Is it possible to insert a component into the detail view page (News)?

Subject. I want to display the latest materials from the section, under each news.
But in my case, it should be inside the detailed view of the news itself.
The component code is not converted to a component. Which exit?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Emelyanov, 2016-07-06
@babarun

I don’t know all the nuances of your task, but I see three ways to solve it:
1. Create an IB property of type text, put the component code in it, and in the template do an eval of the content of this property, if it is not empty. It is fraught with runtime errors and the component code will only be inserted at a predetermined location in the template, i.e. in the middle of the news it will not be possible to insert it.
2. In the detailed description, right in the text of the news, where you need to insert the component, place a tag, for example: PATH_TO_FILE, place the component code in the file, and replace this tag in the template with the result of executing the file with the component. The downside of this solution is a potential php injection.
3. The first two methods can be combined: store the component code in the holy IS, and place a tag or label (for example, #COMPONENT_HERE#) in the news text where it needs to be inserted.

S
Sergey, 2016-07-07
@gangstarcj

If you want the latest materials under each news, then why do you need to insert the component code into the element itself?
If this is a complex component, then paste it in detail.php, if it is a normal one, then in component_epilog.php.

A
Alexey Ukolov, 2016-07-06
@alexey-m-ukolov

The component code is not converted to a component.
What?
Just insert a call to the required component in the detailed news template and that's it. If you do exactly this and it doesn’t work, then you are doing something wrong and until you provide the code, we cannot help you with anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question