Answer the question
In order to leave comments, you need to log in
Bitrix. How to load different infoblocks depending on the URL?
There is such a task. It is necessary to insert such a block into the Bitrix template, in which the information will depend on the page to which we will go.
As far as I understand, this block needs to be written directly in the template, and not on a specific page, and a certain component must be written into it, which should load various info blocks into itself, depending on the address where we are.
I can't figure out how to do it
Answer the question
In order to leave comments, you need to log in
as an option to make an infoblock where to store the url pages and the id of the infoblock to display, check the match of the url on the hit and substitute the desired infoblock
Well, there are different options.
The most classic is to bind to folders on the site. Enter one folder - there is your own index.php, enter another - there is another index.php - you can write different components in them.
If you can have a bunch of addresses with parameters within one folder, such as
/catalog/
/catalog/category-name/category-name/product-name,
then you either use a standard written catalog component
or write your own component. It will work in a nutshell like this:
1) get the address
2) cut off the folder in which we are now
3) split the rest according to previously known rules (if you want, you can read about .urlrewrite.php - it's just about these rules)
4) shove parameters into the request in order to tear out information
5) display information in accordance with the template
Bitrix is not the first convenience system, often you have to run from one place to another. It is much more convenient when the site modules are in the modules/ folder, for example, and inside each there are model + view + controller folders - then you can immediately see where the layout is, where the queries to the database are, and where is the script that connects one and the other in the right order.
Unfortunately, ALL modern CMS prefer to do the opposite - first split into model / view / controller, and then fuck with the same names around the clock, constantly jumping from folder to folder, like a kangaroo
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question