We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16899
    • 284 Posts
    Hi guys

    I´m building a filter form with Advsearch plugin, but now i´m having some troubles in filtering prices.
    How can i put this working?

    Many thanks in advance,
    Legues

    The form part is this one:

    <select name="pricerange" class="selecter">
    	<option selected="selected" value="all">Select a price range</option>
    	<option value="all">Any</option>
    	<option>0-500,000€</option>
    	<option>500,000-1,000,000€</option>
    	<option>1,000,000-1,500,000€</option>
    	<option>1,500,000-2,000,000€</option>
    	<option>>2,000,000€</option>
    </select>
    


    I´m using this QueryHook

    /**
     * AdvSearch
     *
     * Copyright 2012 by Coroico <[email protected]>
     *
     * QueryHook for Faceted search demo 1
     *
     */
    
    $andConditions = array(
        'tv.property-type:=' => 'type:request:all',
        'tv.property-number-bedrooms:=' => 'bedrooms:request:all',
        'tv.property-location:=' => 'location:request:all'
    );
    
    $requests = array();
    
    // price
    $tag = 'pricerange';
    $pricerange = strip_tags($_GET[$tag]);
    if (!empty($pricerange)) {
        $vpricerange = substr($pricerange,0,-1); // to clear the money unit
        if ($vpricerange == '>2,000,000') {
    		$andConditions['tv.property-price:>'] = '2,000,000:numfield';
        }
        else {
            list($pinf,$psup) = explode('-',$vpricerange);
    		$andConditions['tv.property-price:>='] = $pinf.':numfield';
    		$andConditions['tv.property-price:<='] = $psup.':numfield';
        }
    
        // propagate the http request variable for pagination
        $requests['pricerange'] = $pricerange;
    };
    
    $qhDeclaration = array(
        'qhVersion' => '1.2',
    	'andConditions' => $andConditions,
    	'requests' => $requests
    );
    
    $hook->setQueryHook($qhDeclaration);
    return true;
    

    This question has been answered by howster. See the first response.

    [ed. note: legues last edited this post 11 years, 1 month ago.]
      • 16899
      • 284 Posts
      Hi guys

      Now i´m having this almost working... values grater than 1,000,000 works, less than 1,000,000 don´t! Is this related to the number of number characters?
        • 16899
        • 284 Posts
        Any sugestions?
        • discuss.answer
          • 12410
          • 353 Posts
          Been a long time since I used advsearch but I set the prices like this:

          <select style="width: 88px;" name="minp">
                      <option value="none" selected="selected">Min Price</option>
                      <option value="750000">€750,000</option>
                      <option value="1250000">€1,250,000</option>
                      <option value="2250000">€2,250,000</option>
                      <option value="3250000">€3,250,000</option>
                      <option value="5000000">€5,000,000</option>
                      <option value="10000000">€10,000,000</option>
                      <option value="20000000">€20,000,000</option>
                    </select></td>
                    <td><select style="width: 88px;" name="maxp">
                      <option value="none" selected="selected">Max Price</option>
                      <option value="1250000">€1,250,000</option>
                      <option value="2250000">€2,250,000</option>
                      <option value="3250000">€3,250,000</option>
                      <option value="5000000">€5,000,000</option>
                      <option value="10000000">€10,000,000</option>
                      <option value="20000000">€20,000,000</option>
                      <option value="30000000">€30,000,000</option>
                    </select>



          And snippet was:

          <?php
          /**
           * AdvSearch
           *
           * Copyright 2012 by Coroico <[email protected]>
           *
           * QueryHook for Faceted search demo 2
           *
           */
          
          $andConditions = array(
          'tv.property_type:=' => 'property_type:request:all',
              'tv.bedrooms:>=' => 'minb:request:none',
              'tv.bedrooms:<=' => 'maxb:request:none',
           'tv.property_price:>=' => 'minp:request:none',
              'tv.property_price:<=' => 'maxp:request:none',
          'tv.property_area:<=' => 'area:request:none'
             
          );
          
          $qhDeclaration = array(
              'qhVersion' => '1.2',
          	'sortby' => 'sort',		
          	'perPage' => 'ppage',	
          	'andConditions' => $andConditions
          );
          
          $hook->setQueryHook($qhDeclaration);
          return true;


          Set option values to numbers only eg 1000000 not 1,000,000 etc That's all the help I can offer.
            • 16899
            • 284 Posts
            Many thanks, really very appreciated!!! I think i´ll follow your code, instead of having a Price range in options, i think i´ll put min and max values!!! It´s easier and makes all the sense!! smiley I´ll test your code!!

            Many Thnaks Howster