W
W
wocsom2017-10-26 10:01:22
PHP
wocsom, 2017-10-26 10:01:22

How to set up a list array filtering on a page?

I am attaching the source
https://cloud.mail.ru/public/FKHa/So2UeNPsa
The problem is the following, lists of magnetic cards are formed on the page. Unfortunately, magnetic cards are displayed only for today's date. Regardless of setting the date manually. However, if you remove $arFilter in this place of the filter, then cards for previous dates will appear, although not in full.

$res = CIBlockElement::GetList(Array("PROPERTY_P_FIO"=>"ASC"), $arFilter, false, false, $arSelect);

Please help with the solution, because I am not a developer or even a junior...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
Wocsom, 2017-10-27
@wocsom

The decision turned out to be banal. It was necessary to remove a few lines and correct the page for a normal look.
Added:

$res = CIBlockElement::GetList(Array("DATE_ACTIVE_FROM"=>"DESC"), $arFilter, false, false, $arSelect);
    $res->NavStart(10); 
    $res->bShowAll = true;
    $res->GetPageNavString('Привет!');
echo $res->GetPageNavStringEx($navComponentObject, 'Заголовок', '', 'Y');

Removed:
if(!empty($_REQUEST['date_from'])){
                if (new DateTime($_REQUEST['date_from'] . ' 23:59') < new DateTime($r['DATE_ACTIVE_FROM']))
                    continue;
                if (new DateTime($_REQUEST['date_from'] . ' 00:00') > new DateTime($r['DATE_ACTIVE_TO']))
                    continue;
            }else {
                if (new DateTime(date('d.m.Y') . ' 23:59') < new DateTime($r['DATE_ACTIVE_FROM']))
                    continue;
                if (new DateTime(date('d.m.Y') . ' 00:00') > new DateTime($r['DATE_ACTIVE_TO']))
                    continue;
            }

if(empty($r['PROPERTY_P_DATE_VALUE']) || $DB->CompareDates($r['PROPERTY_P_DATE_VALUE'], ConvertTimeStamp() . '00:00') >=0 ) {}

I
Ilya, 2017-10-26
@rpsv

You need to specify the desired condition in arFilter . For example:
$arFilter['>=ACTIVE_FROM'] = date(\DATE_ATOM);

A
Alexey Emelyanov, 2017-10-26
@babarun

Add code

echo '<pre>';
print_r($arFilter);
echo '</pre>';

in front of your
$res = CIBlockElement::GetList(Array("PROPERTY_P_FIO"=>"ASC"), $arFilter, false, false, $arSelect);

And we will see the sampling conditions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question