I
I
I'm Yoda2017-09-09 10:11:59
PHP
I'm Yoda, 2017-09-09 10:11:59

How to randomize section output in catalog.section.list?

Hello connoisseurs!
How can I display 3 random sections marked with a custom field "New" in catalog.section.list?
I select by custom field:

$arFilter = array(
        "ACTIVE" => "Y",
        "GLOBAL_ACTIVE" => "Y",
        "IBLOCK_ID" => $arParams["IBLOCK_ID"],
        "CNT_ACTIVE" => "Y",
        "!UF_NEW_COLLECTION" => 0, // Пользовательское поле "Новинка"
    );

Number of items to display: How to apply random sorting for catalog.section.list??? When displaying elements, you can apply sorting like this: This does not work in catalog.section.list! Where to dig comrades?
$arNavStartParams = Array("nTopCount" => 3);
$arOrder = Array("RAND" => "ASC");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-09-09
@Anadi

Get all sections, and then do array_shuffle and select the first three

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question