Y
Y
Yuri Voronin2017-08-02 18:04:33
PHP
Yuri Voronin, 2017-08-02 18:04:33

Where is the error in displaying catalog elements through catalog.section and catalog.element?

Hello. It is necessary to display the elements of the catalog.
Structure: Infoblock -> Infoblock elements IS
settings:
Information block page URL: /podobrat-dver/
Detailed view page URL: /podobrat-dver/#ELEMENT_CODE#/

<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.section", 
  "catalog_list", 
  array(
                 ....
    "DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
    "SECTION_CODE" => $_REQUEST["SECTION_CODE"],
    "SECTION_ID" => "",
    "SECTION_ID_VARIABLE" => "ELEMENT_CODE",
    "SECTION_URL" => "",
    "SHOW_ALL_WO_SECTION" => "Y",
                 ....
  ),
  false
);?>

<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.element", 
  "detail",
  array(
    .....
    "IBLOCK_ID" => "30",
    "ELEMENT_ID" => "",
    "ELEMENT_CODE" => $_REQUEST["ELEMENT_CODE"],
    "SECTION_ID" => "",
    "SECTION_CODE" => $_REQUEST["SECTION_CODE"],
    "SECTION_URL" => "",
    "DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
    "SECTION_ID_VARIABLE" => "ELEMENT_CODE",
    "SECTION_CODE_PATH" => ""
                 .....
  ),
  false
);?>

Registered UrlRewrite:
"CONDITION" => "#^/podobrat-dver/([a-z0-9\-]+)/(\?.*|)$#",
        "RULE" => "CODE=$1",
        "ID" => "",
        "PATH" => "/podobrat-dver/detail.php",

As a result, on the list page, the URL is built correctly, there is a transition to the detailed page, but it says that the element will not be found. What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2017-08-02
@yuraSco

bitrix:catalog.element - displays a product card
bitrix:catalog.section - section content.
Accordingly, you should have two rules in urlrewrite.php

// Для элемента
array(
  "CONDITION" => "#^/podobrat-dver/([a-z0-9\-]+)/([^/\?]*)(.*)$#",
  "RULE" => "SECION_CODE=\$1&ELEMENT_CODE=\$2&$3",
  "PATH" => "/podobrat-dver/detail.php",
)
// Для раздела
array(
  "CONDITION" => "#^/podobrat-dver/([a-z0-9\-]+)/(.*)$#",
  "RULE" => "SECION_CODE=$1&$2",
  "PATH" => "/podobrat-dver/section.php",
)

Accordingly, on the detail.php page, you should have a call to one component:
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.element", 
  "detail",
  array(
    .....
    "IBLOCK_ID" => "30",
    "ELEMENT_ID" => "",
    "ELEMENT_CODE" => $_REQUEST["ELEMENT_CODE"],
    "SECTION_ID" => "",
    "SECTION_CODE" => $_REQUEST["SECION_CODE"],
    "SECTION_URL" => "",
    "DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
    "SECTION_ID_VARIABLE" => "ELEMENT_CODE",
    "SECTION_CODE_PATH" => ""
                 .....
  ),
  false
);?>

And in the section.php page, you should have a single component call:
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.section", 
  "catalog_list", 
  array(
                 ....
    "DETAIL_URL" => "/podobrat-dver/#ELEMENT_CODE#/",
    "SECTION_CODE" => $_REQUEST["SECTION_CODE"],
    "SECTION_ID" => "",
    "SECTION_URL" => "",
    "SHOW_ALL_WO_SECTION" => "Y",
                 ....
  ),
  false
);?>

I can’t vouch for regular seasons (I wrote offhand, without testing)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question