<![CDATA[ AdvSearch won't return anything from a custom Search filter form and queryHook (but works fine via 'off the shelf' search input) - My Forums]]> https://forums.modx.com/thread/?thread=102105 <![CDATA[AdvSearch won't return anything from a custom Search filter form and queryHook (but works fine via 'off the shelf' search input)]]> https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-550273
I've got AdvSearch running fine with an 'off the shelf' search via input field, returning results fine in the standard format. It's running in Revolution 2.5.5-pl, via MAMP on MacOS 10.12.4, PHP 5.5.10, MySQL 5.5.34. I have Zend lib 1.2 installed in what I think is the required location.

I need to integrate search filtering to return a range of resources based on TVs. I built a custom form and queryHook for this following the guides in the AdvSearch download docs: advSearch101_v1.0.pdf and advsearchHook120_v1.0.pdf. But currently what I've built isn't returning anything from the custom form searches, either filtered or unfiltered.

I need my search to return a range of properties based on: Location, Sleeps (amount), Bedrooms (amount).

I've set up some TVs - [[*Location]] [[*Sleeps]] [[*Bedrooms]] - and 4 Resources are using them. The TVs are each Listboxes (Single select), with appropriate Input Option numeric or text values, and are not set to Allow Blank. They all work fine as they render elsewhere via hard-coded references in the page template.

So here's what I've built so far to get this Search running - apologies for non-indented/highlighted code:

Snippet calls:
[[!AdvSearchForm? &tpl=`filter2SearchForm` ]]
Results:
[[!AdvSearch? &queryHook=`Filter2QHook` &includeTVs=`Location, Sleeps, Bedrooms` &withFields=`introtext,description,content` ]]


Search form (filter2SearchForm):
<form class="advsea-search-form" action="[[~[[+landing]]]]" method="[[+method]]"> 

<fieldset> 
<input type="hidden" name="id" value="[[+landing]]" /> 
<input type="hidden" name="asId" value="[[+asId]]" /> 

<label>Select a Location:  
<select name="ctgLoc" > 
<option value="all" selected="selected">-All Locations -</option> 
<option>North</option> 
<option>East</option>
<option>South</option> 
<option>West</option>
</select> 
</label>

<label>Bedrooms:  
<select name="ctgBed"> 
<option value="all" selected="selected">Any</option> 
<option>2</option> 
<option>3</option> 
<option>4</option> 
<option>5+</option> 
</select>
</label>

<label>Sleeps:  
<select name="ctgSle">
<option value="all" selected="selected">Any</option> 
<option>4</option> 
<option>5</option> 
<option>6</option> 
<option>7</option> 
<option>8+</option> 
</select> 
</label>
 
<input type="submit" name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" /> 

</fieldset> 
</form> 
[[+resultsWindow]] 



queryHook (Filter2QHook):
<?php
$andConditions = array( 
'tv.Location:=' => 'ctgLoc:request:all', 
'tv.Bedrooms:=' => 'ctgBed:request:all',
'tv.Sleeps:=' => 'ctgSle:request:all',
); 
$qhDeclaration = array( 
'qhVersion' => '2.0.0-beta2'
'andConditions' => $andConditions
); 
$hook->setQueryHook($qhDeclaration); 
return true;


In the queryHook you'll see that I used 'qhVersion' => '2.0.0-beta2' as that's the version of AdvSearch.

At this point I'm getting no results at all from this. Can anyone let me know if there's any glaring omission and/or error here?

Any help/advice would be much appreciated.
Thanks in advance.]]>
powellian Apr 25, 2017, 02:34 PM https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-550273
<![CDATA[Re: AdvSearch won't return anything from a custom Search filter form and queryHook (but works fine via 'off the shelf' search input)]]> https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-552319
This didn't fix the issue; I'm going to re-approach this shortly as it's not required for the project right now but I'd like to get a better handle on this extra in general. As/when I fix it I'll write up what the problem was.

Thanks]]>
powellian Jul 06, 2017, 08:55 PM https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-552319
<![CDATA[Re: AdvSearch won't return anything from a custom Search filter form and queryHook (but works fine via 'off the shelf' search input)]]> https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-550741 'qhVersion' => '1.3'

https://github.com/Coroico/AdvSearch/blob/Development/core/components/advsearch/model/advsearch/advsearchhooks.class.php#L184]]>
goldsky May 15, 2017, 04:51 AM https://forums.modx.com/thread/102105/advsearch-won-t-return-anything-from-a-custom-search-filter-form-and-queryhook-but-works-fine-via-off-the-shelf-search-input#dis-post-550741