Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions

searchcontext filter


Reply

2 Posts   1402 Views

Avatar
Neven

17 January 2010 at 2:56am Community Member, 1 Post

Hi, ovo je moje prvo pitanje na ovom forumu

I'm using searchcontext logic for my search form but I have problem.

Code:

static $searchable_fields = array(
         'Naziv' => 'PartialMatchFilter',
         'Cat' => 'PartialMatchFilter',
         'Mapid' => 'ExactMatchFilter',
      );

//////

   function InfoResults($searchCriteria = array()) {
   
       $request = ($this->request) ? $this->request : $this->parentController->getRequest();
       if(!$searchCriteria) $searchCriteria = $request->requestVars();
   
      $start = ($request->getVar('start')) ? (int)$request->getVar('start') : 0;
      $limit = $this->stat('podataka_po_strani');
      
      $context = singleton('Info')->getDefaultSearchContext();
      $query = $context->getQuery($searchCriteria, null, array('start'=>$start,'limit'=>$limit));   

      $records = $context->getResults($searchCriteria, null, array('start'=>$start,'limit'=>$limit));

      if($records) {
         $records->setPageLimits($start, $limit, $query->unlimitedRowCount());
      }   
   
      return $records;
   }

Everything works well but How do I add a permanent filter in the results, regardless of the query such as "WHERE `Cat` NOT LIKE '%ulic%'"

Thanks for any hint!

Avatar
Ingo

25 January 2010 at 12:35pm Forum Moderator, 801 Posts

Hm, either by prepopulating your search form (through HiddenField or default values for other formfields), or by modifying $searchCriteria in your controller code before invoking getResults()