A
A
Airslip2017-02-06 13:40:56
Batteries
Airslip, 2017-02-06 13:40:56

How to link section elements (bitrix:catalog.section) and detailed catalog element (bitrix:catalog.element)?

Greetings to all, help me understand the situation: there are two pages in one folder - index.php and detail.php. Bitrix:catalog.section component has been added to index.php, which displays the contents of the infoblock section.
Output code:

<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.section", 
  "sofas2", 
  array(
    "TEMPLATE_THEME" => "blue",
    "PRODUCT_SUBSCRIPTION" => "N",
    "SHOW_DISCOUNT_PERCENT" => "N",
    "SHOW_OLD_PRICE" => "N",
    "ADD_TO_BASKET_ACTION" => "ADD",
    "SHOW_CLOSE_POPUP" => "N",
    "MESS_BTN_BUY" => "Купить",
    "MESS_BTN_ADD_TO_BASKET" => "В корзину",
    "MESS_BTN_SUBSCRIBE" => "Подписаться",
    "MESS_BTN_DETAIL" => "Подробнее",
    "MESS_NOT_AVAILABLE" => "Нет в наличии",
    "AJAX_MODE" => "N",
    "SEF_MODE" => "Y",
    "IBLOCK_TYPE" => "exchangetest",
    "IBLOCK_ID" => "69",
    "SECTION_ID" => "179",
    "SECTION_CODE" => "",
    "SECTION_USER_FIELDS" => array(
      0 => "",
      1 => "",
    ),
    "ELEMENT_SORT_FIELD" => "sort",
    "ELEMENT_SORT_ORDER" => "asc",
    "ELEMENT_SORT_FIELD2" => "id",
    "ELEMENT_SORT_ORDER2" => "desc",
    "FILTER_NAME" => "arrFilter",
    "INCLUDE_SUBSECTIONS" => "Y",
    "SHOW_ALL_WO_SECTION" => "N",
    "SECTION_URL" => "",
    "DETAIL_URL" => "#ELEMENT_CODE#/",
    "SECTION_ID_VARIABLE" => "SECTION_ID",
    "SET_TITLE" => "N",
    "SET_BROWSER_TITLE" => "N",
    "BROWSER_TITLE" => "-",
    "SET_META_KEYWORDS" => "Y",
    "META_KEYWORDS" => "-",
    "SET_META_DESCRIPTION" => "Y",
    "META_DESCRIPTION" => "-",
    "ADD_SECTIONS_CHAIN" => "N",
    "DISPLAY_COMPARE" => "N",
    "SET_STATUS_404" => "N",
    "PAGE_ELEMENT_COUNT" => "30",
    "LINE_ELEMENT_COUNT" => "3",
    "PROPERTY_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_LIMIT" => "5",
    "PRICE_CODE" => array(
    ),
    "USE_PRICE_COUNT" => "N",
    "SHOW_PRICE_COUNT" => "1",
    "PRICE_VAT_INCLUDE" => "Y",
    "BASKET_URL" => "/personal/basket.php",
    "ACTION_VARIABLE" => "action",
    "PRODUCT_ID_VARIABLE" => "id",
    "USE_PRODUCT_QUANTITY" => "N",
    "PRODUCT_QUANTITY_VARIABLE" => "quantity",
    "ADD_PROPERTIES_TO_BASKET" => "Y",
    "PRODUCT_PROPS_VARIABLE" => "prop",
    "PARTIAL_PRODUCT_PROPERTIES" => "N",
    "PRODUCT_PROPERTIES" => array(
    ),
    "CACHE_TYPE" => "A",
    "CACHE_TIME" => "36000000",
    "CACHE_NOTES" => "",
    "CACHE_FILTER" => "N",
    "CACHE_GROUPS" => "Y",
    "PAGER_TEMPLATE" => ".default",
    "DISPLAY_TOP_PAGER" => "N",
    "DISPLAY_BOTTOM_PAGER" => "Y",
    "PAGER_TITLE" => "Товары",
    "PAGER_SHOW_ALWAYS" => "N",
    "PAGER_DESC_NUMBERING" => "N",
    "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
    "PAGER_SHOW_ALL" => "N",
    "HIDE_NOT_AVAILABLE" => "N",
    "CONVERT_CURRENCY" => "N",
    "AJAX_OPTION_JUMP" => "N",
    "AJAX_OPTION_STYLE" => "Y",
    "AJAX_OPTION_HISTORY" => "N",
    "OFFERS_FIELD_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_PROPERTY_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_SORT_FIELD" => "sort",
    "OFFERS_SORT_ORDER" => "asc",
    "OFFERS_SORT_FIELD2" => "id",
    "OFFERS_SORT_ORDER2" => "desc",
    "PRODUCT_DISPLAY_MODE" => "N",
    "ADD_PICT_PROP" => "-",
    "LABEL_PROP" => "-",
    "MESS_BTN_COMPARE" => "Сравнить",
    "OFFERS_CART_PROPERTIES" => array(
    ),
    "AJAX_OPTION_ADDITIONAL" => ""
  ),
  false
);?>

The bitrix:catalog.element component has been added to detail.php.
His code:
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.element", 
  ".default", 
  array(
    "TEMPLATE_THEME" => "blue",
    "DISPLAY_NAME" => "Y",
    "DETAIL_PICTURE_MODE" => "IMG",
    "ADD_DETAIL_TO_SLIDER" => "N",
    "DISPLAY_PREVIEW_TEXT_MODE" => "E",
    "PRODUCT_SUBSCRIPTION" => "N",
    "SHOW_DISCOUNT_PERCENT" => "N",
    "SHOW_OLD_PRICE" => "N",
    "SHOW_MAX_QUANTITY" => "N",
    "ADD_TO_BASKET_ACTION" => array(
      0 => "BUY",
    ),
    "SHOW_CLOSE_POPUP" => "N",
    "MESS_BTN_BUY" => "Купить",
    "MESS_BTN_ADD_TO_BASKET" => "В корзину",
    "MESS_BTN_SUBSCRIBE" => "Подписаться",
    "MESS_NOT_AVAILABLE" => "Нет в наличии",
    "USE_VOTE_RATING" => "N",
    "USE_COMMENTS" => "N",
    "IBLOCK_TYPE" => "exchangetest",
    "IBLOCK_ID" => "69",
    "ELEMENT_ID" => $_REQUEST["ELEMENT_ID"],
    "ELEMENT_CODE" => "",
    "SECTION_ID" => $_REQUEST["SECTION_ID"],
    "SECTION_CODE" => "",
    "SECTION_URL" => "",
    "DETAIL_URL" => "",
    "SECTION_ID_VARIABLE" => "ELEMENT_ID",
    "CHECK_SECTION_ID_VARIABLE" => "N",
    "SET_TITLE" => "Y",
    "SET_BROWSER_TITLE" => "Y",
    "BROWSER_TITLE" => "-",
    "SET_META_KEYWORDS" => "Y",
    "META_KEYWORDS" => "-",
    "SET_META_DESCRIPTION" => "Y",
    "META_DESCRIPTION" => "-",
    "SET_STATUS_404" => "N",
    "ADD_SECTIONS_CHAIN" => "Y",
    "ADD_ELEMENT_CHAIN" => "N",
    "PROPERTY_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_LIMIT" => "0",
    "PRICE_CODE" => array(
    ),
    "USE_PRICE_COUNT" => "N",
    "SHOW_PRICE_COUNT" => "1",
    "PRICE_VAT_INCLUDE" => "Y",
    "PRICE_VAT_SHOW_VALUE" => "N",
    "BASKET_URL" => "/personal/basket.php",
    "ACTION_VARIABLE" => "action",
    "PRODUCT_ID_VARIABLE" => "id",
    "USE_PRODUCT_QUANTITY" => "N",
    "PRODUCT_QUANTITY_VARIABLE" => "quantity",
    "ADD_PROPERTIES_TO_BASKET" => "Y",
    "PRODUCT_PROPS_VARIABLE" => "prop",
    "PARTIAL_PRODUCT_PROPERTIES" => "N",
    "PRODUCT_PROPERTIES" => array(
    ),
    "DISPLAY_COMPARE" => "N",
    "LINK_IBLOCK_TYPE" => "",
    "LINK_IBLOCK_ID" => "",
    "LINK_PROPERTY_SID" => "",
    "LINK_ELEMENTS_URL" => "link.php?PARENT_ELEMENT_ID=#ELEMENT_ID#",
    "CACHE_TYPE" => "A",
    "CACHE_TIME" => "36000000",
    "CACHE_NOTES" => "",
    "CACHE_GROUPS" => "Y",
    "USE_ELEMENT_COUNTER" => "Y",
    "HIDE_NOT_AVAILABLE" => "N",
    "CONVERT_CURRENCY" => "N",
    "OFFERS_FIELD_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_PROPERTY_CODE" => array(
      0 => "",
      1 => "",
    ),
    "OFFERS_SORT_FIELD" => "sort",
    "OFFERS_SORT_ORDER" => "asc",
    "OFFERS_SORT_FIELD2" => "id",
    "OFFERS_SORT_ORDER2" => "desc",
    "ADD_PICT_PROP" => "-",
    "LABEL_PROP" => "-",
    "OFFER_ADD_PICT_PROP" => "-",
    "OFFER_TREE_PROPS" => array(
      0 => "-",
    ),
    "MESS_BTN_COMPARE" => "Сравнить",
    "OFFERS_CART_PROPERTIES" => array(
    )
  ),
  false
);?>

How to connect these two components? So that when you click on the elements in Index.php, the detail.php page opens and displays the specified element in detail?
UPD: I found a problem, someone wrote a condition in the urlrewrite file, because of which I was constantly thrown into the bases folder. When I removed it, everything worked.
array(
    "CONDITION" => "#^/#",
    "RULE" => "",
    "ID" => "bitrix:catalog",
    "PATH" => "/bases/index.php",
),

Many thanks to everyone who responded.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikita, 2017-02-06
@Airslip

Coming to the general form of links, the component with sections throws out #ELEMENT_CODE#, and on the detail page you accept $_REQUEST["ELEMENT_ID"] - not a match.
If you want to make NC normal, then in address processing you need to add a rule,
#^/catalog/([a-z0-9\-]+)/(\?.*|)$# for page /catalog/detail.php with rule CODE=$1

A
Airslip, 2017-02-06
@Airslip

Everything seems to be clear, I corrected the code of the detailed page:

"IBLOCK_ID" => "69",
    "ELEMENT_ID" => $_REQUEST["ELEMENT_CODE"],
    "ELEMENT_CODE" => "",

In urlrewrite.php file added:
array(
    "CONDITION" => "#^/sofas2/direct/([a-z0-9\-]+)/(\?.*|)$#",
    "RULE" => "CODE=$1",
    "ID" => "",
    "PATH" => "/sofas2/direct/detail.php",
  ),

But still doesn't work

R
Roman Gritsuk, 2017-02-06
@winer

if you need to make a section in which there will be a list of products with links to the product card, then use the complex catalog component .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question