On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • AdvSearch noob question.

    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. [ed. note: powellian last edited this post 2 years, 7 months ago.]
      • Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
      • Sorry for this über-late reply, thanks for answering.

        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