I am using Joomla 3.9 version.Basically I am developing search page where user can type keyword in search input and get list of all related list of article as result.Below is some sort of code I am working

$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
//set the application parameters
        $appParams = JFactory::getApplication()->getParams();
        $model->setState('params',$appParams);

        //start the list of content from the beginning
        $model->setState('list.start',0);

        //gets how many to stop at from parameters or sets as 5
        $model->setState('list.limit',(int) $params->get('count',5));

        //filters out unpublished content
        $model->setState('filter.published',1);

      $model->setState('a.id, a.fulltext, a.title, a.alias, a.title_alias, a.introtext, a.state, a.catid');

    //sorts out the ordering
        switch($params->get('ordering'))
        {
            case 'pubAsc':
                $model->setState('list.ordering','publish_up');
                $model->setState('list.direction', 'ASC');
                break;
            case 'pubDesc':
                $model->setState('list.ordering','publish_up');
                $model->setState('list.direction', 'DESC');
                break;
        default:
                $model->setState('list.ordering', 'a.created');
                $model->setState('list.direction', 'DESC');
                break;

      }

    //filter out other languages
        $model->setState('filter.language',$app->getLanguageFilter());
        if($params->get('feat') == 1){
            $model->setState('filter.featured','only');
        }

        $items = $model->getItems();
        return $items;                      

Note : This code is working fine with other filter in switch case But when  try to search article with  article name 
like
$model->setState('filter.search', 'Some article name or title keyword');

Result is not filtered,  getting  full list of article(no search filter applied). Please any body can suggest how can I filter article by name

0 Answers