V
V
VladPolanski2018-08-22 07:43:36
1C-Bitrix
VladPolanski, 2018-08-22 07:43:36

How to override url in template.php?

Dear experts of Bitrix. Such is my question. There is a complex catalog component.
I have a condition in template.php

if($arItem["CODE"] == ""){
    $arItem["DETAIL_PAGE_URL"] .= $arItem["NAME"].$arItem["DISPLAY_PROPERTIES"]["SIZE"]["~VALUE"] 
}

If the symbolic code of the element is not filled, then the detailed page has the form that is written in the condition.
$arItem["DETAIL_PAGE_URL"] in the resulting array is overwritten - but when you follow the link, it says Page not found. What to do? Tell.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-08-22
@VladPolanski

Why should it work?
Well, there is a component A that displays the URL in the template of which this code is written. OK. It outputs this URL.
And there is a component B which displays products by URL. You opened this URL, but how can component B even know that in this particular case it is necessary to search for a product not with the foo150 code, but with the name foo and size 150?
There is no reason for this implementation to work and no way for you to make it work. Those. in principle, this can be done, but it is difficult (suffice it to say that you will have to write your own component) and unnecessary, because even if you need such logic, it can be implemented differently.
Make an element creation and modification interceptor, and if it does not have a code filled in, fill in the code automatically by substituting $arItem["NAME"].$arItem["DISPLAY_PROPERTIES"]["SIZE"]["~VALUE"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question