S
S
Sergey Serov2017-04-12 20:01:09
1C-Bitrix
Sergey Serov, 2017-04-12 20:01:09

How to display voting in the right place of the detailed page in Bitrix?

Site on Bitrix, edition Start.
In the settings of the News component, I check the box Allow voting. Voting appears on the detailed one, but at the very bottom, because in detail.php "bitrix:iblock.vote" is located under "bitrix:news.detail".
I want to place a vote under the title of the posted news.
I tried to take the code from detail.php

<?$APPLICATION->IncludeComponent(
  "bitrix:iblock.vote",
  "stars",
  Array(
    "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
    "IBLOCK_ID" => $arParams["IBLOCK_ID"],
    "ELEMENT_ID" => $ElementID,
    "MAX_VOTE" => $arParams["MAX_VOTE"],
    "VOTE_NAMES" => $arParams["VOTE_NAMES"],
    "CACHE_TYPE" => $arParams["CACHE_TYPE"],
    "CACHE_TIME" => $arParams["CACHE_TIME"],
  ),
  $component
);?>

and insert into bitrix/news.detail/.default/template.php but it doesn't work like that.
It says "Photo not found."
Can you please tell me how to display the vote in the right place of the detailed page?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Serov, 2017-04-25
@nodot

As a result, they helped in technical support. The problem was that $ElementID is determined only at the moment of connecting bitrix:news.detail

<?$ElementID = $APPLICATION->IncludeComponent(
   "bitrix:news.detail",

because of this, the voting component did not receive the ID of the element for which to display the rating.
By analogy with the standard catalog component template, you can place the voting component inside the bitrix:news.detail template, and not inside bitrix:news.
<?$APPLICATION->IncludeComponent(
            "bitrix:iblock.vote",
            "stars",
            array(
                "IBLOCK_TYPE" => $arParams['IBLOCK_TYPE'],
                "IBLOCK_ID" => $arParams['IBLOCK_ID'],
                "ELEMENT_ID" => $arResult['ID'],
                "ELEMENT_CODE" => "",
                "MAX_VOTE" => "5",
                "VOTE_NAMES" => array("1", "2", "3", "4", "5"),
                "SET_STATUS_404" => "N",
                "DISPLAY_AS_RATING" => $arParams['VOTE_DISPLAY_AS_RATING'],
                "CACHE_TYPE" => $arParams['CACHE_TYPE'],
                "CACHE_TIME" => $arParams['CACHE_TIME']
            ),
            $component,
            array("HIDE_ICONS" => "Y")
        );?>

S
Sergey, 2017-04-12
@SirBataneg

Component in the news body

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question