A
A
Alexander Petrov2016-07-26 18:07:43
PHP
Alexander Petrov, 2016-07-26 18:07:43

Can't filter by content in Bitrix?

I'm trying to filter sections like this:

<ul>
<?
$arSelect=array('UF_TITLE','UF_KEYWORDS','UF_DESCRIPTION','UF_AFTER_TEXT','UF_ALT');
$arFilter=array( 
    'IBLOCK_ID' => 1,
    array( 
        "LOGIC" => "OR", 
        'NAME'=>'%'.$_REQUEST['q'].'%', 
        'DESCRIPTION'=>'%'.$_REQUEST['q'].'%', 
    ),     
);
$rsSect = CIBlockSection::GetList(array('left_margin' => 'asc'),$arFilter,false,$arSelect);
while ($arSect = $rsSect->GetNext())
{ 
   ?>
   <li><a href="<?=$arSect['SECTION_PAGE_URL']?>"><?=$arSect['NAME']?></a></li><? 
} 

?>
</ul>

$_REQUEST['q'] - contains the word to be found.
By NAME it searches normally, but not by DESCRIPTION .... maybe because there is html there?
How to find a word in DESCRIPTION?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Harakhnin, 2016-07-26
@Chupokabr

$arFilter=array( 
    'IBLOCK_ID' => 1,
    array( 
        "LOGIC" => "OR", 
        array('NAME'=>'%'.$_REQUEST['q'].'%'), 
        array('UF_DESCRIPTION'=>'%'.$_REQUEST['q'].'%'), 
    ),     
);

Try like this

A
Alexey Emelyanov, 2016-07-27
@babarun

Судя по коду метода CIBlockSection::GetFilter, фильтровать по полю DESCRIPTION нельзя.
Нужно искать обходные пути или поправить метод.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question